From a59cef7e1a1a978b926b5a39c8d567e94e5918e6 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 16 Sep 2007 11:36:58 +0300 Subject: [PATCH] imported winuaesrc1440b8.zip --- bsdsocket.c | 7 ++- filesys.c | 20 +++++-- od-win32/bsdsock.c | 100 ++++++++++++++++++++++------------- od-win32/win32.h | 4 +- od-win32/win32gui.c | 7 ++- od-win32/winuaechangelog.txt | 9 ++++ 6 files changed, 101 insertions(+), 46 deletions(-) diff --git a/bsdsocket.c b/bsdsocket.c index f80fca88..c2752d0c 100755 --- a/bsdsocket.c +++ b/bsdsocket.c @@ -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[] = { diff --git a/filesys.c b/filesys.c index 46eda7cb..a3a859f9 100755 --- 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; } diff --git a/od-win32/bsdsock.c b/od-win32/bsdsock.c index 2d0babee..9bde3c60 100755 --- a/od-win32/bsdsock.c +++ b/od-win32/bsdsock.c @@ -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; } diff --git a/od-win32/win32.h b/od-win32/win32.h index 4ad5f98e..99abcbd2 100755 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -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 "" diff --git a/od-win32/win32gui.c b/od-win32/win32gui.c index 0ca2de7d..069e5014 100755 --- a/od-win32/win32gui.c +++ b/od-win32/win32gui.c @@ -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; diff --git a/od-win32/winuaechangelog.txt b/od-win32/winuaechangelog.txt index 9ec0dedf..59203ee4 100755 --- a/od-win32/winuaechangelog.txt +++ b/od-win32/winuaechangelog.txt @@ -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: -- 2.47.3