[or-cvs] r10823: Fixed some IOCP bugs. IOCP code fully written but not fully (in libevent-urz/trunk: loaders sample)

Urz at seul.org Urz at seul.org
Fri Jul 13 08:41:18 UTC 2007


Author: Urz
Date: 2007-07-13 04:41:18 -0400 (Fri, 13 Jul 2007)
New Revision: 10823

Modified:
   libevent-urz/trunk/loaders/IOCPloader.c
   libevent-urz/trunk/sample/IOCPloader-test.c
Log:
Fixed some IOCP bugs. IOCP code fully written but not fully debugged. Current issue is a segfault when calling WSASend (but only sometimes)

Modified: libevent-urz/trunk/loaders/IOCPloader.c
===================================================================
--- libevent-urz/trunk/loaders/IOCPloader.c	2007-07-12 23:52:25 UTC (rev 10822)
+++ libevent-urz/trunk/loaders/IOCPloader.c	2007-07-13 08:41:18 UTC (rev 10823)
@@ -32,6 +32,8 @@
     DWORD listSearch;
     char found = 0;
     
+    printf("Bind Start\n");
+    
     ev_lock(listLock);
     
     for(listSearch = 0; listSearch < listSize; listSearch++) {
@@ -50,8 +52,8 @@
         myListElem = listSize;
         listSize++;
         
-        eventList = realloc(eventList, sizeof(HANDLE *) * listSize);
-        connList = realloc(connList, sizeof(connection *) * listSize);
+        eventList = realloc(eventList, sizeof(HANDLE) * listSize);
+        connList = realloc(connList, sizeof(connection) * listSize);
         
     } else {
         ev_lock(connList[myListElem].lock);
@@ -89,13 +91,14 @@
     connList[myListElem].canSend = 1;
     connList[myListElem].inUse = 1;
     
-    ev_unlock(connList[myListElem].lock);
-    
     // Despite the name, this call associates the socket with the I/O Completion port
     IOCP = CreateIoCompletionPort(connList[myListElem].sock, IOCP, (ULONG_PTR) myListElem, 0);
     
+    ev_unlock(connList[myListElem].lock);
     ev_unlock(listLock);
     
+    printf("Bind End\n");
+    
     return (int) myListElem;
 }
 
@@ -150,6 +153,8 @@
         ev_unlock(listLock);
         Sleep(1000);
         
+        printf("S");
+        
         for(listpos = 0; listpos < localListSize; listpos++) {
             
             ev_lock(connList[listpos].lock);
@@ -167,6 +172,7 @@
                 // assume the WSABUF is full?
                 // remind us that sending is in progress and we can't overwrite the buffer
                 connList[listpos].canSend = 0;
+                printf("Sock : %d (pos %d)\n", (int) connList[listpos].sock, (int) listpos);
                 WSASend(
                     *(connList[listpos].sock),
                     // Socket to send on
@@ -223,6 +229,7 @@
             continue;
         }
         
+        printf("R");
         
         // This is no error, a completed read event has occured.
         // Get the connection ths applies to.

Modified: libevent-urz/trunk/sample/IOCPloader-test.c
===================================================================
--- libevent-urz/trunk/sample/IOCPloader-test.c	2007-07-12 23:52:25 UTC (rev 10822)
+++ libevent-urz/trunk/sample/IOCPloader-test.c	2007-07-13 08:41:18 UTC (rev 10823)
@@ -116,14 +116,13 @@
     char buf[BUF_SIZE];
     int error;
     
+    WSAStartup(MAKEWORD( 2, 2 ), &wsaData);
+    IOCPLoaderInit();
     event_init();
     
     lsabe = sa_bufferevent_new(listener_on_read, NULL, NULL, NULL);
-    // Obviously one or more of these has to be changed to be not-null
+    // Obviously one or more of these has to be changed to be not-null
     
-    WSAStartup(MAKEWORD( 2, 2 ), &wsaData);
-    IOCPLoaderInit();
-    
     Listen = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED);
     
     if(Listen == INVALID_SOCKET) {



More information about the tor-commits mailing list