Revision: 481
          http://vde.svn.sourceforge.net/vde/?rev=481&view=rev
Author:   rd235
Date:     2011-03-27 20:53:56 +0000 (Sun, 27 Mar 2011)

Log Message:
-----------
step two point five: propagate modifications to kvde_switch, handle_input 
becomes handle_io

Modified Paths:
--------------
    branches/rd235/vde-2/src/dpipe.c
    branches/rd235/vde-2/src/kvde_switch/consmgmt.c
    branches/rd235/vde-2/src/kvde_switch/datasock.c
    branches/rd235/vde-2/src/kvde_switch/kvde_switch.c
    branches/rd235/vde-2/src/vde_switch/consmgmt.c
    branches/rd235/vde-2/src/vde_switch/datasock.c
    branches/rd235/vde-2/src/vde_switch/switch.h
    branches/rd235/vde-2/src/vde_switch/tuntap.c
    branches/rd235/vde-2/src/vde_switch/vde_switch.c

Modified: branches/rd235/vde-2/src/dpipe.c
===================================================================
--- branches/rd235/vde-2/src/dpipe.c    2011-03-27 09:07:52 UTC (rev 480)
+++ branches/rd235/vde-2/src/dpipe.c    2011-03-27 20:53:56 UTC (rev 481)
@@ -114,7 +114,7 @@
                                        close(p1[0]);
                                        break;
                                default:
-                                       fprintf(stderr,"CHECA\n");
+                                       fprintf(stderr,"Error\n");
                        }
                        execvp(argv1[0],argv1);
                } else {
@@ -136,7 +136,7 @@
                                        close(p1[1]);
                                        break;
                                default:
-                                       fprintf(stderr,"CHECA\n");
+                                       fprintf(stderr,"Error\n");
                        }
                        recmain(argc-split-1,argv2,newdirchar);
                }
@@ -151,11 +151,72 @@
        char **argv1,**argv2;
        int p1[2],p2[2];
        int dirchar=0;
+       int daemonize=0;
+       char *pidfile=NULL;
+       int pgrp;
+       int argflag;
+       int err=0;
 
        progname=argv[0];
        argv++;
        argc--;
 
+       do {
+               argflag=0;
+               if (argv[0] && *argv[0] == '-') {
+                       argflag++;
+                       argv[0]++;
+                       if (*argv[0] == '-') {
+                               argv[0]++;
+                               if (strcmp(argv[0],"daemon") == 0)
+                                       daemonize = 1;
+                               else if (strcmp(argv[0],"pidfile") == 0) {
+                                       pidfile = argv[argflag];
+                                       argflag++;
+                               } else {
+                                       fprintf(stderr,"unknown option 
--%s\n",argv[0]);
+                                       err++;
+                               }
+                       } else {
+                               while (*argv[0] != 0) {
+                                       switch (*argv[0]) {
+                                               case 0: break;
+                                               case 'd': daemonize = 1; break;
+                                               case 'p': pidfile = 
argv[argflag];
+                                                                               
        argflag++;
+                                                                               
        break;
+                                               default: 
fprintf(stderr,"unknown option -%c\n",*argv[0]);
+                                                                               
 err++;
+                                       }
+                                       if (*argv[0] != 0) argv[0]++;
+                               }
+                       }
+                       argv += argflag;
+                       argc -= argflag;
+               }
+       } while (argflag);
+
+       if (err)
+               exit(1);
+
+       if (setpgrp() == 0)
+               pgrp = getpgrp();
+       else {
+               fprintf(stderr,"Err: cannot create pgrp\n");
+               exit(1);
+       }
+
+       if (daemonize != 0)
+               daemon(0,0);
+
+       if (pidfile != NULL) {
+               FILE *f=fopen(pidfile, "w");
+               if (f != NULL) {
+                       fprintf(f,"-%d\n",pgrp);
+                       fclose(f);
+               }
+       }
+
        alternate_fd();
        split=splitindex(argc,argv,&dirchar);
 

Modified: branches/rd235/vde-2/src/kvde_switch/consmgmt.c
===================================================================
--- branches/rd235/vde-2/src/kvde_switch/consmgmt.c     2011-03-27 09:07:52 UTC 
(rev 480)
+++ branches/rd235/vde-2/src/kvde_switch/consmgmt.c     2011-03-27 20:53:56 UTC 
(rev 481)
@@ -381,7 +381,7 @@
                return;
        }
 
-       add_fd(new,mgmt_data,-1);
+       add_fd(new,mgmt_data,NULL);
        EVENTOUT(MGMTPORTNEW,new);
        snprintf(buf,MAXCMD,header,PACKAGE_VERSION);
        write(new,buf,strlen(buf));
@@ -392,7 +392,7 @@
 static int debugdel(int fd,char *arg);
 #endif
 static char *EOS="9999 END OF SESSION";
-static void handle_input(unsigned char type,int fd,int revents,int *unused)
+static void handle_io(unsigned char type,int fd,int revents,void *unused)
 {
        char buf[MAXCMD];
        if (type != mgmt_ctl) {
@@ -451,7 +451,7 @@
                        return;
                }
 
-               add_fd(new,mgmt_data,-1);
+               add_fd(new,mgmt_data,NULL);
                EVENTOUT(MGMTPORTNEW,new);
                snprintf(buf,MAXCMD,header,PACKAGE_VERSION);
                write(new,buf,strlen(buf));
@@ -489,7 +489,7 @@
        fclose(f);
 }
 
-static void cleanup(unsigned char type,int fd,int arg)
+static void cleanup(unsigned char type,int fd,void *unused)
 {
        if (fd < 0) {
                if((pidfile != NULL) && unlink(pidfile_path) < 0) {
@@ -570,7 +570,7 @@
        if(isatty(0) && !daemonize)
        {
                console_type=add_type(&swmi,0);
-               add_fd(0,console_type,-1);
+               add_fd(0,console_type,NULL);
        }
 
        /* saves current path in pidfile_path, because otherwise with 
daemonize() we
@@ -623,7 +623,7 @@
                }
                mgmt_ctl=add_type(&swmi,0);
                mgmt_data=add_type(&swmi,0);
-               add_fd(mgmtconnfd,mgmt_ctl,-1);
+               add_fd(mgmtconnfd,mgmt_ctl,NULL);
        }
 }
 
@@ -867,7 +867,7 @@
        swmi.usage=usage;
        swmi.parseopt=parseopt;
        swmi.init=init;
-       swmi.handle_input=handle_input;
+       swmi.handle_io=handle_io;
        swmi.cleanup=cleanup;
        ADDCL(cl);
 #ifdef DEBUGOPT

Modified: branches/rd235/vde-2/src/kvde_switch/datasock.c
===================================================================
--- branches/rd235/vde-2/src/kvde_switch/datasock.c     2011-03-27 09:07:52 UTC 
(rev 480)
+++ branches/rd235/vde-2/src/kvde_switch/datasock.c     2011-03-27 20:53:56 UTC 
(rev 481)
@@ -48,12 +48,12 @@
 
 #define MODULENAME "kernel module interface"
 
-static void handle_input(unsigned char type,int fd,int revents,int *arg)
+static void handle_io(unsigned char type,int fd,int revents,void *arg)
 {
        /*here OOB messages will be delivered for debug options */
 }
 
-static void cleanup(unsigned char type,int fd,int arg)
+static void cleanup(unsigned char type,int fd,void *unused)
 {
        unlink(ctl_socket);
 }
@@ -215,7 +215,7 @@
                exit(1);
        }
        runextinterfaces(&sun);
-       add_fd(kvdefd,ctl_type,-1);
+       add_fd(kvdefd,ctl_type,NULL);
 }
 
 static int showinfo(FILE *fd)
@@ -247,7 +247,7 @@
        swmi.usage=usage;
        swmi.parseopt=parseopt;
        swmi.init=init;
-       swmi.handle_input=handle_input;
+       swmi.handle_io=handle_io;
        swmi.cleanup=cleanup;
        ADDCL(cl);
        add_swm(&swmi);

Modified: branches/rd235/vde-2/src/kvde_switch/kvde_switch.c
===================================================================
--- branches/rd235/vde-2/src/kvde_switch/kvde_switch.c  2011-03-27 09:07:52 UTC 
(rev 480)
+++ branches/rd235/vde-2/src/kvde_switch/kvde_switch.c  2011-03-27 20:53:56 UTC 
(rev 481)
@@ -79,7 +79,7 @@
 /* FD MGMT */
 struct pollplus {
        unsigned char type;
-       int arg;
+       void *private_data;
        time_t timestamp;
 };
 
@@ -131,7 +131,7 @@
        ntypes--;
 }
 
-void add_fd(int fd,unsigned char type,int arg)
+void add_fd(int fd,unsigned char type,void *private_data)
 {
        struct pollfd *p;
        int index;
@@ -162,7 +162,7 @@
        p->fd = fd;
        p->events = POLLIN | POLLHUP;
        fdpp[index]->type=type;
-       fdpp[index]->arg=arg;
+       fdpp[index]->private_data=private_data;
        nfds++;
 }
 
@@ -170,7 +170,7 @@
 {
        register int i;
        for(i = 0; i < nfds; i++)
-               
TYPE2MGR(fdpp[i]->type)->cleanup(fdpp[i]->type,fds[i].fd,fdpp[i]->arg);
+               
TYPE2MGR(fdpp[i]->type)->cleanup(fdpp[i]->type,fds[i].fd,fdpp[i]->private_data);
 }
 
 void remove_fd(int fd)
@@ -184,7 +184,7 @@
                printlog(LOG_WARNING,"remove_fd : Couldn't find descriptor %d", 
fd);
        } else {
                struct pollplus *old=fdpp[i];
-               
TYPE2MGR(fdpp[i]->type)->cleanup(fdpp[i]->type,fds[i].fd,fdpp[i]->arg);
+               
TYPE2MGR(fdpp[i]->type)->cleanup(fdpp[i]->type,fds[i].fd,fdpp[i]->private_data);
                if (ISPRIO(fdpp[i]->type)) nprio--;
                memmove(&fds[i], &fds[i + 1], (maxfds - i - 1) * sizeof(struct 
pollfd));
                memmove(&fdpp[i], &fdpp[i + 1], (maxfds - i - 1) * 
sizeof(struct pollplus *));
@@ -209,7 +209,7 @@
                                        register int prenfds=nfds;
                                        n--;
                                        fdpp[i]->timestamp=now;
-                                       
TYPE2MGR(fdpp[i]->type)->handle_input(fdpp[i]->type,fds[i].fd,fds[i].revents,&(fdpp[i]->arg));
+                                       
TYPE2MGR(fdpp[i]->type)->handle_io(fdpp[i]->type,fds[i].fd,fds[i].revents,fdpp[i]->private_data);
                                        if (nfds!=prenfds) /* the current fd 
has been deleted */
                                                break; /* PERFORMANCE it is 
faster returning to poll */
                                }       
@@ -375,7 +375,7 @@
        file_cleanup();
        for(swmp=swmh;swmp != NULL;swmp=swmp->next)
                if (swmp->cleanup != NULL)
-                       swmp->cleanup(0,-1,-1);
+                       swmp->cleanup(0,-1,NULL);
 }
 
 static void sig_handler(int sig)

Modified: branches/rd235/vde-2/src/vde_switch/consmgmt.c
===================================================================
--- branches/rd235/vde-2/src/vde_switch/consmgmt.c      2011-03-27 09:07:52 UTC 
(rev 480)
+++ branches/rd235/vde-2/src/vde_switch/consmgmt.c      2011-03-27 20:53:56 UTC 
(rev 481)
@@ -381,7 +381,7 @@
 static int debugdel(int fd,char *arg);
 #endif
 static char *EOS="9999 END OF SESSION";
-static void handle_input(unsigned char type,int fd,int revents,void 
*private_data)
+static void handle_io(unsigned char type,int fd,int revents,void *private_data)
 {
        char buf[MAXCMD];
        if (type != mgmt_ctl) {
@@ -942,7 +942,7 @@
        swmi.usage=usage;
        swmi.parseopt=parseopt;
        swmi.init=init;
-       swmi.handle_input=handle_input;
+       swmi.handle_io=handle_io;
        swmi.cleanup=cleanup;
        ADDCL(cl);
 #ifdef DEBUGOPT

Modified: branches/rd235/vde-2/src/vde_switch/datasock.c
===================================================================
--- branches/rd235/vde-2/src/vde_switch/datasock.c      2011-03-27 09:07:52 UTC 
(rev 480)
+++ branches/rd235/vde-2/src/vde_switch/datasock.c      2011-03-27 20:53:56 UTC 
(rev 481)
@@ -205,7 +205,7 @@
        }
 }
 
-static void handle_input(unsigned char type,int fd,int revents,void *arg)
+static void handle_io(unsigned char type,int fd,int revents,void *arg)
 {
        struct endpoint *ep=arg;
        if (type == data_type) {
@@ -504,7 +504,7 @@
        swmi.usage=usage;
        swmi.parseopt=parseopt;
        swmi.init=init;
-       swmi.handle_input=handle_input;
+       swmi.handle_io=handle_io;
        swmi.cleanup=cleanup;
        modfun.sender=send_datasock;
        modfun.delep=delep;

Modified: branches/rd235/vde-2/src/vde_switch/switch.h
===================================================================
--- branches/rd235/vde-2/src/vde_switch/switch.h        2011-03-27 09:07:52 UTC 
(rev 480)
+++ branches/rd235/vde-2/src/vde_switch/switch.h        2011-03-27 20:53:56 UTC 
(rev 481)
@@ -36,7 +36,7 @@
        void (*usage)(void); /* usage function: command line opts explanation */
        int (*parseopt)(int parm,char *optarg); /* parse getopt output */
        void (*init)(void); /* init */
-       void (*handle_input)(unsigned char type,int fd,int revents,void 
*private_data); /* handle input */
+       void (*handle_io)(unsigned char type,int fd,int revents,void 
*private_data); /* handle input */
        void (*cleanup)(unsigned char type,int fd,void *private_data); 
/*cleanup for files or final if fd == -1 */
        struct swmodule *next;
 };

Modified: branches/rd235/vde-2/src/vde_switch/tuntap.c
===================================================================
--- branches/rd235/vde-2/src/vde_switch/tuntap.c        2011-03-27 09:07:52 UTC 
(rev 480)
+++ branches/rd235/vde-2/src/vde_switch/tuntap.c        2011-03-27 20:53:56 UTC 
(rev 481)
@@ -71,7 +71,7 @@
        return 0;
 }
 
-static void handle_input(unsigned char type,int fd,int revents,void 
*private_data)
+static void handle_io(unsigned char type,int fd,int revents,void *private_data)
 {
        struct endpoint *ep=private_data;
        struct bipacket packet;
@@ -252,7 +252,7 @@
        swmi.usage=usage;
        swmi.parseopt=parseopt;
        swmi.init=init;
-       swmi.handle_input=handle_input;
+       swmi.handle_io=handle_io;
        swmi.cleanup=cleanup;
        modfun.sender=send_tap;
        modfun.delep=delep;

Modified: branches/rd235/vde-2/src/vde_switch/vde_switch.c
===================================================================
--- branches/rd235/vde-2/src/vde_switch/vde_switch.c    2011-03-27 09:07:52 UTC 
(rev 480)
+++ branches/rd235/vde-2/src/vde_switch/vde_switch.c    2011-03-27 20:53:56 UTC 
(rev 481)
@@ -278,7 +278,7 @@
                                        register int prenfds=nfds;
                                        n--;
                                        fdpp[i]->timestamp=now;
-                                       
TYPE2MGR(fdpp[i]->type)->handle_input(fdpp[i]->type,fds[i].fd,fds[i].revents,fdpp[i]->private_data);
+                                       
TYPE2MGR(fdpp[i]->type)->handle_io(fdpp[i]->type,fds[i].fd,fds[i].revents,fdpp[i]->private_data);
                                        if (nfds!=prenfds) /* the current fd 
has been deleted */
                                                break; /* PERFORMANCE it is 
faster returning to poll */
                                }       


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
vde-users mailing list
vde-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vde-users

Reply via email to