ayttm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ayttm-commits] CVS: ayttm/modules/msn2/libmsn2 msn_bittybits.C,1.16,1.1


From: Colin Leroy <address@hidden>
Subject: [Ayttm-commits] CVS: ayttm/modules/msn2/libmsn2 msn_bittybits.C,1.16,1.17
Date: Sun, 30 Mar 2003 06:17:13 -0500

Update of /cvsroot/ayttm/ayttm/modules/msn2/libmsn2
In directory subversions:/tmp/cvs-serv3193/modules/msn2/libmsn2

Modified Files:
        msn_bittybits.C 
Log Message:
select instead of poll


Index: msn_bittybits.C
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/msn2/libmsn2/msn_bittybits.C,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- msn_bittybits.C     27 Mar 2003 12:57:08 -0000      1.16
+++ msn_bittybits.C     30 Mar 2003 11:17:11 -0000      1.17
@@ -24,64 +24,48 @@
   int should_terminate=0;
   int sock = conn->sock;
   int finished = 0;
-#ifndef __MINGW32__
-  struct pollfd pfd;
-  struct timespec delay;
+  fd_set inp;
+  struct timeval tv;
   
-  pfd.fd=sock;
-  pfd.events=POLLIN;
+  FD_ZERO(&inp);
+  FD_SET(sock, &inp);
 
-  delay.tv_sec = 0;
-  delay.tv_nsec = 10000000;
-#endif
-  do
+  tv.tv_sec = 0;
+  tv.tv_usec = 0;
+
+  while(select(sock+1, &inp, NULL, NULL, &tv))
   {
     
-    if(read(sock, &c, 1)<1)
-    {
-      if (errno == EAGAIN) {  
-#ifdef __MINGW32__
-       int j;
-       for (int i=0; i<10000000;i++)
-               j=i;
-#else
-       int res=0;
-       if((res=poll(&pfd,1,5000))==0) {
-               *numargs=0;
-               return NULL;
-       } else if (res > 0) {
-               continue;
+       if(FD_ISSET(sock, &inp)) {
+               if(read(sock, &c, 1)<1) {
+                       if (errno == EAGAIN) {
+                               continue;
+                       } else if (errno) {
+                               printf("error %d %s\n",errno, strerror(errno));
+                               printf("What the.. (%d) (%s)?!\n", sock, 
conn->readbuf); //DEBUG
+                               *numargs=-1;
+                               return NULL;      
+                       } else if(conn->type==CONN_FTP) {
+                               conn->numspaces++; 
conn->readbuf[conn->pos]='\0'; finished=1; break;
+                       }
+               }
+               if(conn->pos == 1249) {conn->readbuf[conn->pos]='\0'; continue; 
}
+               if(c=='\r' || conn->pos > 1249) { continue; }
+               if(c=='\n') { conn->numspaces++; conn->readbuf[conn->pos]='\0'; 
finished=1; break; }
+               if(c==' ') { conn->numspaces++; }
+               conn->readbuf[conn->pos]=c;
+               conn->pos++;
        } else {
-               *numargs=-1;
-               return NULL;
+               break;
        }
-       
-#endif
-       continue;
-      } else if (errno) {
-       printf("error %d %s\n",errno, strerror(errno));
-        printf("What the.. (%d) (%s)?!\n", sock, conn->readbuf); //DEBUG
-       *numargs=-1;
-       return NULL;      
-      }        else if(conn->type==CONN_FTP)
-         { conn->numspaces++; conn->readbuf[conn->pos]='\0'; finished=1; 
break; }            
-    }
 
-    if(conn->pos == 1249) {conn->readbuf[conn->pos]='\0'; continue; }
-    if(c=='\r' || conn->pos > 1249) { continue; }
-    if(c=='\n') { conn->numspaces++; conn->readbuf[conn->pos]='\0'; 
finished=1; break; }
-    if(c==' ') { conn->numspaces++; }
-    conn->readbuf[conn->pos]=c;
-    conn->pos++;
+       FD_ZERO(&inp);
+       FD_SET(sock, &inp);
   }
-#ifndef __MINGW32__
-  while(poll(&pfd, 1, 0)==1);
-#else
-  while (1);
-#endif
   if (!finished) {
-         *numargs=0;
-         return NULL;
+    *numargs=0;
+    printf("incomplete read !\n");
+    return NULL;
   }
   
   if(conn->numspaces==0) { printf("What the..?\n"); *numargs=-1; return NULL; }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]