]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
imported winuaesrc1440b8.zip
authorToni Wilen <twilen@winuae.net>
Sun, 16 Sep 2007 08:36:58 +0000 (11:36 +0300)
committerToni Wilen <twilen@winuae.net>
Mon, 22 Feb 2010 19:35:51 +0000 (21:35 +0200)
bsdsocket.c
filesys.c
od-win32/bsdsock.c
od-win32/win32.h
od-win32/win32gui.c
od-win32/winuaechangelog.txt

index f80fca882002f26be94caea79259b5373e83ba93..c2752d0cf7aaafeee4af67adc514f8e570ac63d6 100755 (executable)
@@ -1420,10 +1420,14 @@ void bsdlib_reset (void)
 
     SockLibBase = 0;
 
-    for (sb = socketbases; sb; sb = nsb) {
+       write_log("BSDSOCK: cleanup starting..\n");
+       host_sbcleanup (NULL);
+       for (sb = socketbases; sb; sb = nsb) {
        nsb = sb->next;
 
+       write_log("BSDSOCK: cleanup start socket %x\n", sb);
        host_sbcleanup (sb);
+       write_log("BSDSOCK: cleanup end\n");
 
        free (sb->dtable);
        free (sb->ftable);
@@ -1444,6 +1448,7 @@ void bsdlib_reset (void)
     }
 
     host_sbreset ();
+       write_log("BSDSOCK: cleanup end\n");
 }
 
 static const TrapHandler sockfuncs[] = {
index 46eda7cb33df9630bec8751e744d3c32a31cb1f9..a3a859f9ca987a56dacc25b13ba46b7faa278407 100755 (executable)
--- a/filesys.c
+++ b/filesys.c
@@ -2724,6 +2724,7 @@ static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaec
     uae_u32 flags = 15, days, mins, ticks;
     struct stat statbuf;
     int fsdb_can = fsdb_cando (unit);
+    uae_u16 uid = 0, gid = 0;
 
     memset(&statbuf, 0, sizeof statbuf);
     if (unit->volflags & MYVOLUMEINFO_ARCHIVE)
@@ -2767,6 +2768,11 @@ static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaec
        size += strlen (comment) + 1;
        size = (size + 3) & ~3;
     }
+    if (control >= 7) {
+       size2 += 4;
+       uid = 0;
+       gid = 0;
+    }
 
     i = get_long (control + 0);
     while (i > 0) {
@@ -2806,6 +2812,10 @@ static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaec
            size2++;
        }
     }
+    if (control >= 7) {
+       put_word (exp + 36, uid);
+       put_word (exp + 38, gid);
+    }
     put_long (control + 0, get_long (control + 0) + 1);
     return 1;
 }
@@ -2900,8 +2910,12 @@ static int action_examine_all (Unit *unit, dpacket packet)
 
     ok = 0;
 
-    //write_log ("exall: %08x %08x-%08x %d %d %08x\n", lock, exalldata, exalldata + exalldatasize, exalldatasize, type, control);
-    //write_log ("exall: MatchString %08x, MatchFunc %08x\n", get_long (control + 8), get_long (control + 12));
+#if 0
+    write_log ("exall: %08x %08x-%08x %d %d %08x\n",
+       lock, exalldata, exalldata + exalldatasize, exalldatasize, type, control);
+    write_log ("exall: MatchString %08x, MatchFunc %08x\n",
+       get_long (control + 8), get_long (control + 12));
+#endif
 
     put_long (control + 0, 0); /* eac_Entries */
 
@@ -2909,7 +2923,7 @@ static int action_examine_all (Unit *unit, dpacket packet)
     if (kickstart_version < 36)
        return 0;
 
-    if (type == 0 || type > 6) {
+    if (type == 0 || type > 7) {
        doserr = ERROR_BAD_NUMBER;
        goto fail;
     }
index 2d0babee637ad688a05a898ca8f245715f81feac..9bde3c6046444063568dc2a3cc366a8f52211d1d 100755 (executable)
@@ -222,10 +222,39 @@ int init_socket_layer(void)
        return result;
 }
 
-void deinit_socket_layer(void)
+static void close_selectget_threads(void)
 {
        int i;
 
+       for (i = 0; i < MAX_SELECT_THREADS; i++) {
+               if (bsd->hEvents[i]) {
+                       HANDLE h = bsd->hEvents[i];
+                       bsd->hEvents[i] = NULL;
+                       CloseHandle (h);
+               }
+               if (bsd->hThreads[i]) {
+                       CloseHandle (bsd->hThreads[i]);
+                       bsd->hThreads[i] = NULL;
+               }
+       }
+
+       for (i = 0; i < MAX_GET_THREADS; i++) {
+               if (bsd->hGetThreads[i]) {
+                       HANDLE h = bsd->hGetThreads[i];
+                       bsd->hGetThreads[i] = NULL;
+                       CloseHandle (h);
+               }
+               if (bsd->hGetEvents[i]) {
+                       CloseHandle (bsd->hGetEvents[i]);
+                       bsd->hGetEvents[i] = NULL;
+               }
+               bsd->threadGetargs_inuse[i] = 0;
+       }
+
+}
+
+void deinit_socket_layer(void)
+{
        if (!bsd)
            return;
        WSACleanup();
@@ -245,27 +274,7 @@ void deinit_socket_layer(void)
                DestroyWindow (bsd->hSockWnd);
                bsd->hSockWnd = NULL;
        }
-       for (i = 0; i < MAX_SELECT_THREADS; i++) {
-               if (bsd->hThreads[i]) {
-                       CloseHandle (bsd->hThreads[i]);
-                       bsd->hThreads[i] = NULL;
-               }
-               if (bsd->hEvents[i]) {
-                       CloseHandle (bsd->hEvents[i]);
-                       bsd->hEvents[i] = NULL;
-               }
-       }
-       for (i = 0; i < MAX_GET_THREADS; i++) {
-               if (bsd->hGetThreads[i]) {
-                       CloseHandle (bsd->hGetThreads[i]);
-                       bsd->hGetThreads[i] = NULL;
-               }
-               if (bsd->hGetEvents[i]) {
-                       CloseHandle (bsd->hGetEvents[i]);
-                       bsd->hGetEvents[i] = NULL;
-               }
-               bsd->threadGetargs_inuse[i] = 0;
-       }
+       close_selectget_threads ();
 }
 
 #ifdef BSDSOCKET
@@ -311,11 +320,11 @@ int host_sbinit(TrapContext *context, SB)
 
 void host_closesocketquick(SOCKET s)
 {
-       BOOL true = 1;
+       BOOL b = 1;
 
        if(s) {
-           setsockopt(s,SOL_SOCKET,SO_DONTLINGER,(char *)&true,sizeof(true));
-           shutdown(s,1);
+           setsockopt(s, SOL_SOCKET, SO_DONTLINGER, (char *)&b, sizeof(b));
+           shutdown(s, 1);
            closesocket(s);
        }
 }
@@ -324,6 +333,11 @@ void host_sbcleanup(SB)
 {
        int i;
 
+       if (!sb) {
+               close_selectget_threads ();
+               return;
+       }
+
        for (i = 0; i < MAXPENDINGASYNC; i++) {
                if (bsd->asyncsb[i] == sb)
                        bsd->asyncsb[i] = NULL;
@@ -340,7 +354,7 @@ void host_sbcleanup(SB)
                        bsd->asyncsb[(sb->mtable[i] - 0xb000) / 2] = NULL;
        }
 
-       shutdown(sb->sockAbort,1);
+       shutdown(sb->sockAbort, 1);
        closesocket(sb->sockAbort);
 
        free(sb->mtable);
@@ -677,7 +691,7 @@ void host_accept(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 nam
        }
     TRACE(("accept(%d,%d,%d) -> ",sd,name,hlenuae));
 
-    s = (SOCKET)getsock(sb, (int)sd);
+    s = getsock(sb, (int)sd);
 
     if (s != INVALID_SOCKET) {
                BEGINBLOCKING;
@@ -938,7 +952,7 @@ void host_connect(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 na
        if (!addr_valid("host_connect", name, namelen))
                return;
 
-    s = (SOCKET)getsock(sb,(int)sd);
+    s = getsock(sb,(int)sd);
 
     if (s != INVALID_SOCKET) {
                if (namelen <= MAXADDRLEN) {
@@ -1664,7 +1678,7 @@ static void fd_zero(uae_u32 fdset, uae_u32 nfds)
 static unsigned int thread_WaitSelect2(void *indexp)
 {
     int index = *((int*)indexp);
-    unsigned int result = 0;
+    unsigned int result = 0, resultval;
     long nfds;
     uae_u32 readfds, writefds, exceptfds;
     uae_u32 timeout;
@@ -1674,8 +1688,11 @@ static unsigned int thread_WaitSelect2(void *indexp)
 
     SB;
 
-    for (;;) {
-           WaitForSingleObject(bsd->hEvents[index], INFINITE);
+       while (bsd->hEvents[index]) {
+           if (WaitForSingleObject(bsd->hEvents[index], INFINITE) == WAIT_ABANDONED)
+                       break;
+               if (bsd->hEvents[index] == NULL)
+                       break;
 
            if ((args = bsd->threadargsw[index]) != NULL) {
                    sb = args->sb;
@@ -1700,8 +1717,11 @@ static unsigned int thread_WaitSelect2(void *indexp)
 
                    TRACE(("-> "));
 
-                   sb->resultval = select(nfds+1, &readsocks, writefds ? &writesocks : NULL,
+                   resultval = select(nfds+1, &readsocks, writefds ? &writesocks : NULL,
                                        exceptfds ? &exceptsocks : NULL, timeout ? &tv : 0);
+                       if (bsd->hEvents[index] == NULL)
+                               break;
+                       sb->resultval = resultval;
                        if (sb->resultval == SOCKET_ERROR) {
                                // select was stopped by sb->sockAbort
                                if (readsocks.fd_count > 1) {
@@ -1709,7 +1729,10 @@ static unsigned int thread_WaitSelect2(void *indexp)
                                        tv.tv_sec = 0;
                                        tv.tv_usec = 10000;
                                        // Check for 10ms if data is available
-                                       sb->resultval = select(nfds+1, &readsocks, writefds ? &writesocks : NULL,exceptfds ? &exceptsocks : NULL,&tv);
+                                       resultval = select(nfds+1, &readsocks, writefds ? &writesocks : NULL,exceptfds ? &exceptsocks : NULL,&tv);
+                                       if (bsd->hEvents[index] == NULL)
+                                               break;
+                                       sb->resultval = resultval;
                                        if (sb->resultval == 0) { // Now timeout -> really no data available
                                                if (GetLastError() != 0) {
                                                        sb->resultval = SOCKET_ERROR;
@@ -1749,6 +1772,7 @@ static unsigned int thread_WaitSelect2(void *indexp)
                    SetEvent(sb->hEvent);
            }
     }
+       write_log ("BSDSOCK: thread_WaitSelect2 terminated\n");
     THREADEND(result);
     return result;
 }
@@ -1982,9 +2006,12 @@ static unsigned int thread_get2(void *indexp)
        char *name_rp;
        SB;
 
-    for (;;) {
+       while (bsd->hGetEvents[index]) {
 
-               WaitForSingleObject(bsd->hGetEvents[index], INFINITE);
+               if (WaitForSingleObject(bsd->hGetEvents[index], INFINITE) == WAIT_ABANDONED)
+                       break;
+               if (bsd->hGetEvents[index] == NULL)
+                       break;
 
                if (bsd->threadGetargs_inuse[index] == -1)
                        bsd->threadGetargs_inuse[index] = 0;
@@ -2092,7 +2119,8 @@ static unsigned int thread_get2(void *indexp)
 
                }
     }
-    THREADEND(result);
+       write_log ("BSDSOCK: thread_get2 terminated\n");
+       THREADEND(result);
     return result;
 }
 
index 4ad5f98e39a46cbcb45ad80cb06cfdd5ce97b59c..99abcbd2f74122eff6d494397fac430905a053bb 100755 (executable)
@@ -15,9 +15,9 @@
 #define GETBDM(x) (((x) - ((x / 10000) * 10000)) / 100)
 #define GETBDD(x) ((x) % 100)
 
-#define WINUAEBETA 7
+#define WINUAEBETA 8
 #define WINUAEPUBLICBETA 1
-#define WINUAEDATE MAKEBD(2007, 9, 15)
+#define WINUAEDATE MAKEBD(2007, 9, 16)
 #define WINUAEEXTRA ""
 #define WINUAEREV ""
 
index 0ca2de7d87ff3179fc16b7a38dee04201b8d2db6..069e5014cdfc82c64a3caad01f44cebfde8a5452 100755 (executable)
@@ -267,7 +267,7 @@ static int drag_start (HWND hWnd, HWND hListView, LPARAM lParam)
     bFirst = TRUE;
     iPos = ListView_GetNextItem(hListView, -1, LVNI_SELECTED);
     while (iPos != -1) {
-       if (bFirst) {
+        if (bFirst) {
            // For the first selected item,
            // we simply create a single-line drag image
            hDragImageList = ListView_CreateDragImage(hListView, iPos, &p);
@@ -279,8 +279,7 @@ static int drag_start (HWND hWnd, HWND hListView, LPARAM lParam)
            // we create a single-line drag image, then
            // append it to the bottom of the complete drag image
            hOneImageList = ListView_CreateDragImage(hListView, iPos, &p);
-           hTempImageList = ImageList_Merge(hDragImageList,
-                            0, hOneImageList, 0, 0, iHeight);
+           hTempImageList = ImageList_Merge(hDragImageList, 0, hOneImageList, 0, 0, iHeight);
            ImageList_Destroy(hDragImageList);
            ImageList_Destroy(hOneImageList);
            hDragImageList = hTempImageList;
@@ -296,7 +295,7 @@ static int drag_start (HWND hWnd, HWND hListView, LPARAM lParam)
     pt = ((NM_LISTVIEW*) ((LPNMHDR)lParam))->ptAction;
     ClientToScreen(hListView, &pt);
 
-    ImageList_DragEnter(GetDesktopWindow(), pt.x, pt.y);
+    ImageList_DragEnter(NULL, pt.x, pt.y);
 
     bDragging = TRUE;
 
index 9ec0dedfa8464f15f024250794f5bda6d0fc8c89..59203ee4fa213a8e20f9d502b11acc169bd6d6bf 100755 (executable)
@@ -1,4 +1,13 @@
 
+Beta 8: (this is basically RC1 if bsdsocket is fixed)
+
+- ExAll ED_OWNER supported (return zero uid and gid) because
+  there are programs that ask for ED_OWNER and ignore
+  ERROR_BAD_NUMBER (as documented in autodocs)
+- possible fix for bsdsocket crash/issues after reset
+  (previously background threads weren't terminated properly and
+  caused random access errors, another ancient bug in bsdsocket..)
+  Also added some cleanup logging.
 
 Beta 7: