Changeset 3139 for trunk/src


Ignore:
Timestamp:
Mar 17, 2000, 5:07:53 PM (25 years ago)
Author:
sandervl
Message:

WSAAsyncSelect fix

Location:
trunk/src/wsock32
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wsock32/makefile

    r3031 r3139  
    1 # $Id: makefile,v 1.20 2000-03-06 23:39:20 bird Exp $
     1# $Id: makefile,v 1.21 2000-03-17 16:06:42 sandervl Exp $
    22
    33#
     
    2828$(OBJDIR)\relaywin.obj \
    2929$(OBJDIR)\wsock32rsrc.obj \
    30 $(PDWIN32_LIB)/dllentry.obj
     30$(OBJDIR)\initterm.obj \
     31#$(OBJDIR)\async.obj \
     32#$(OBJDIR)\asyncthread.obj \
     33$(OBJDIR)\dbglocal.obj
    3134
    3235
  • trunk/src/wsock32/relaywin.cpp

    r3107 r3139  
    4242#include <win32api.h>
    4343#include "wsock32.h"
     44#include <vmutex.h>
     45
     46#define DBG_LOCALLOG    DBG_relaywin
     47#include "dbglocal.h"
    4448
    4549ODINDEBUGCHANNEL(WSOCK32-RELAYWIN)
     
    5660static char*       ODIN_WSOCK_RELAY_CLASS = "ODIN_WSOCK_RELAY";
    5761static HWND        hwndRelay              = NULLHANDLE;
    58 
     62static HAB         hab;
     63static VMutex      relayMutex;
    5964
    6065/*****************************************************************************
     
    8085  ULONG ulCounter;
    8186
    82   for (ulCounter = 0;
    83        ulCounter < MAX_ASYNC_SOCKETS;
    84        ulCounter++)
    85     if ( (arrHwndMsgPair[ulCounter].hwnd == 0) ||    // slot free?
    86          ( (fSingleRequestPerWindow == TRUE) &&      // more than one request
    87                                                      // per window ?
     87  relayMutex.enter();
     88  for(ulCounter = 0; ulCounter < MAX_ASYNC_SOCKETS; ulCounter++)
     89  {
     90        if ( (arrHwndMsgPair[ulCounter].hwnd == 0) ||    // slot free?
     91           ( (fSingleRequestPerWindow == TRUE) &&      // more than one request per window?
    8892           (arrHwndMsgPair[ulCounter].hwnd == hwnd) ) ) // same window?
    89     {
    90       // occupy slot
    91       arrHwndMsgPair[ulCounter].hwnd          = hwnd;
    92       arrHwndMsgPair[ulCounter].ulMsg         = ulMsg;
    93       arrHwndMsgPair[ulCounter].ulRequestType = ulRequestType;
    94       arrHwndMsgPair[ulCounter].pvUserData1   = pvUserData1;
    95       arrHwndMsgPair[ulCounter].pvUserData2   = pvUserData2;
    96       arrHwndMsgPair[ulCounter].pvUserData3   = pvUserData3;
    97       return ulCounter + 1; // return "id"
    98     }
    99 
     93        {
     94                // occupy slot
     95                arrHwndMsgPair[ulCounter].hwnd          = hwnd;
     96                arrHwndMsgPair[ulCounter].ulMsg         = ulMsg;
     97                arrHwndMsgPair[ulCounter].ulRequestType = ulRequestType;
     98                arrHwndMsgPair[ulCounter].pvUserData1   = pvUserData1;
     99                arrHwndMsgPair[ulCounter].pvUserData2   = pvUserData2;
     100                arrHwndMsgPair[ulCounter].pvUserData3   = pvUserData3;
     101                relayMutex.leave();
     102                return ulCounter + 1; // return "id"
     103        }
     104  }
     105  relayMutex.leave();
    100106  return -1; // not found
    101107}
     
    120126    return -1; // error
    121127
     128  relayMutex.enter();
    122129  arrHwndMsgPair[ulID-1].hwnd = 0; // mark free
    123130  arrHwndMsgPair[ulID-1].ulMsg = 0;
     
    126133  arrHwndMsgPair[ulID-1].pvUserData2 = 0;
    127134  arrHwndMsgPair[ulID-1].pvUserData3 = 0;
     135  relayMutex.leave();
    128136
    129137  return 0; // OK
     
    147155  ULONG ulCounter;
    148156
    149   for (ulCounter = 0;
    150        ulCounter < MAX_ASYNC_SOCKETS;
    151        ulCounter++)
    152     if ( arrHwndMsgPair[ulCounter].hwnd == hwnd )  // same window?
    153     {
    154       arrHwndMsgPair[ulCounter].hwnd  = 0; // free slot
    155       return 0; // OK
    156     }
    157 
     157  relayMutex.enter();
     158  for(ulCounter = 0; ulCounter < MAX_ASYNC_SOCKETS; ulCounter++)
     159  {
     160        if ( arrHwndMsgPair[ulCounter].hwnd == hwnd )  // same window?
     161        {
     162                arrHwndMsgPair[ulCounter].hwnd  = 0; // free slot
     163                arrHwndMsgPair[ulCounter].ulMsg = 0;
     164                arrHwndMsgPair[ulCounter].ulRequestType = 0;
     165                arrHwndMsgPair[ulCounter].pvUserData1 = 0;
     166                arrHwndMsgPair[ulCounter].pvUserData2 = 0;
     167                arrHwndMsgPair[ulCounter].pvUserData3 = 0;
     168                relayMutex.leave();
     169                return 0; // OK
     170        }
     171  }
     172  relayMutex.leave();
     173  dprintf(("RelayFreeByHwnd: window %x not found!", hwnd));
    158174  return -1; // not found
    159175}
     
    216232    rc = SHORT1FROMMP(mp2);                /* asynchronous operation result */
    217233
    218     dprintf(("WSOCK32: RelayWindowProc, message %x for window %x with "
    219              "mp1 = %d and mp2 = %d (rc = %d) received\n",
    220              ulMsg, hwnd, mp1, mp2, rc));
     234//    dprintf(("WSOCK32: RelayWindowProc, message %x for window %x with "
     235//             "mp1 = %d and mp2 = %d (rc = %d) (time = %x) received\n",
     236//             ulMsg, hwnd, mp1, mp2, rc, WinQueryMsgTime(hab)));
    221237
    222238    /* check request type for special handling */
     
    228244      case ASYNCREQUEST_SELECT:
    229245      {
    230         dprintf(("WSOCK32:RelayWindowProc, AsyncSelect notification\n"));
     246        dprintf(("WSOCK32:RelayWindowProc, AsyncSelect notification %x %x (%d,%d) time %x\n", pHM->hwnd, pHM->ulMsg, mp1, mp2, WinQueryMsgTime(hab)));
    231247        break;
    232248      }
     
    390406
    391407
    392     dprintf(("WSOCK32:RelayWinProc, Posting hwnd=%08xh, msg=%08xh, w=%08xh, l=%08xh\n",
    393              pHM->hwnd,
    394              pHM->ulMsg,
    395              mp1,
    396              mp2));
     408//    dprintf(("WSOCK32:RelayWinProc, Posting hwnd=%08xh, msg=%08xh, w=%08xh, l=%08xh\n",
     409//             pHM->hwnd,
     410//             pHM->ulMsg,
     411//             mp1,
     412//             mp2));
    397413
    398414    PostMessageA(pHM->hwnd,
     
    439455{
    440456  BOOL       fSuccess;
    441   HAB        hab;
    442457  HWND       hwnd;
    443458
  • trunk/src/wsock32/wsock32.cpp

    r3107 r3139  
    1 /* $Id: wsock32.cpp,v 1.19 2000-03-14 14:59:43 sandervl Exp $ */
     1/* $Id: wsock32.cpp,v 1.20 2000-03-17 16:06:42 sandervl Exp $ */
    22
    33/*
     
    5151#include "wsock32.h"
    5252#include "relaywin.h"
     53#define DBG_LOCALLOG    DBG_wsock32
     54#include "dbglocal.h"
    5355
    5456
     
    6769static HWND hwndRelay = NULL; // handle to our relay window
    6870
     71BOOL fWSAInitialized = FALSE;
    6972
    7073/*****************************************************************************
     
    10701073              LPWSADATA,lpWSAData)
    10711074{
     1075  fWSAInitialized = TRUE;
    10721076  return(WSAStartup(wVersionRequired,
    10731077                    lpWSAData));
     
    10891093ODINFUNCTION0(int,OS2WSACleanup)
    10901094{
     1095  fWSAInitialized = FALSE;
    10911096  return(WSACleanup());
    10921097}
     
    15381543                         wMsg,
    15391544                         ASYNCREQUEST_SELECT,
    1540                          TRUE);
     1545                         FALSE); //SvL: allow multiple selects -> pmwsock should fail if it not allowed
     1546//                         TRUE);
    15411547
    15421548  rc = WSAAsyncSelect(s,
     
    15451551                      lEvent);
    15461552
    1547 //  iError = WSAGetLastError();
    1548 //  dprintf(("res=%d, err=%d\n",
    1549 //           rc,
    1550 //           iError));
     1553  // if an error occurs, free the allocated relay entry
     1554  if (rc == SOCKET_ERROR)
     1555    RelayFree(ulNewID);
     1556
    15511557  return (rc);
    15521558}
  • trunk/src/wsock32/wsock32.h

    r2013 r3139  
    1 /* $Id: wsock32.h,v 1.9 1999-12-07 20:25:48 achimha Exp $ */
     1/* $Id: wsock32.h,v 1.10 2000-03-17 16:06:42 sandervl Exp $ */
    22
    33/* WSOCK32.H--definitions & conversions for Odin's wsock32.dll.
     
    8585
    8686
     87extern BOOL fWSAInitialized;
     88
     89void WIN32API OS2WSASetLastError(int iError);
     90
     91int  WIN32API OS2WSAGetLastError(void);
     92
     93BOOL WIN32API OS2WSAIsBlocking(void);
     94
    8795#endif  /* _WINSOCK32CONST_ */
    8896
Note: See TracChangeset for help on using the changeset viewer.