Changeset 1940 for trunk/src


Ignore:
Timestamp:
Dec 2, 1999, 4:22:05 PM (26 years ago)
Author:
achimha
Message:

async wsock fixes

Location:
trunk/src/wsock32/new
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wsock32/new/relaywin.cpp

    r1933 r1940  
    1 /* $Id: relaywin.cpp,v 1.3 1999-12-02 07:47:26 phaller Exp $ */
     1/* $Id: relaywin.cpp,v 1.4 1999-12-02 15:22:05 achimha Exp $ */
    22
    33/*
     
    3838#include "relaywin.h"
    3939
     40#include <pmwsock.h>
     41#include <os2sel.h>
     42#include <wprocess.h>
     43#include <heapstring.h>
     44#include <win32wnd.h>
     45#include "wsock32.h"
     46
    4047ODINDEBUGCHANNEL(WSOCK32-RELAYWIN)
    4148
     
    5360
    5461// prototype for PostMessageA
    55 //BOOL _Stdcall PostMessageA(HWND,UINT,WPARAM,LPARAM);
    5662BOOL __stdcall PostMessageA(HWND,UINT,ULONG,ULONG);
    5763
     
    6975 *****************************************************************************/
    7076
    71 ULONG RelayAlloc(HWND hwnd, ULONG ulMsg)
     77ULONG RelayAlloc(HWND hwnd, ULONG ulMsg, ULONG ulRequestType,
     78                 PVOID pvUserData1, PVOID pvUserData2)
    7279{
    7380  ULONG ulCounter;
     
    8289      arrHwndMsgPair[ulCounter].hwnd  = hwnd;
    8390      arrHwndMsgPair[ulCounter].ulMsg = ulMsg;
     91      arrHwndMsgPair[ulCounter].ulRequestType = ulRequestType;
     92      arrHwndMsgPair[ulCounter].pvUserData1 = pvUserData1;
     93      arrHwndMsgPair[ulCounter].pvUserData2 = pvUserData2;
    8494      return ulCounter; // return "id"
    8595    }
     
    190200  //   WinDefWindowProc()
    191201 
    192   //@@@PH: 1999/11/31 PROBLEM
    193   // hwnd and ulMsg passed in have been converted by our USER32 code
    194   // here, we ultimatively need to translate it back.
    195   // under the debugger, things WORK now !:)
    196  
    197202  pHM = RelayQuery(ulMsg);                          // find registered message
    198203  if (pHM != NULL)                                  // message pair found
    199204  {
     205    /* check request type for special handling */
     206    if (pHM->ulRequestType == ASYNCREQUEST_GETHOSTBYNAME)
     207    {
     208      dprintf(("WSOCK32:RelayWindowProc, Converting hostent for WSAAyncGetHostByName\n"));
     209      /* we need to convert the hostent structure here */
     210      Whostent *WinHostent = (Whostent*)pHM->pvUserData1;
     211      hostent *OS2Hostent = (hostent*)pHM->pvUserData2;
     212      WinHostent->h_name = OS2Hostent->h_name;
     213      WinHostent->h_aliases = OS2Hostent->h_aliases;
     214      WinHostent->h_addrtype = (short)OS2Hostent->h_addrtype;
     215      WinHostent->h_length = (short)OS2Hostent->h_length;
     216      WinHostent->h_addr_list = OS2Hostent->h_addr_list;
     217      /* free our temporary OS2 hostent buffer */
     218//TODO: how can we free this? we will end up with a memory leak :(
     219// this memory block not only contains the hostent structure but also the strings it points to
     220//      free(pHM->pvUserData2);
     221
     222dprintf(("Size of Window hostent: %d, OS/2 hostent: %d, mp1: %d, mp2 %d\n", sizeof(Whostent), sizeof(hostent), mp1, mp2));
     223
     224    }
     225
     226    dprintf(("WSOCK32:RelayWinProc, Posting %d to %d\n", pHM->ulMsg, pHM->hwnd));
    200227    PostMessageA(pHM->hwnd,
    201228                 pHM->ulMsg,
  • trunk/src/wsock32/new/relaywin.h

    r1933 r1940  
    1 /* $Id: relaywin.h,v 1.2 1999-12-02 07:47:26 phaller Exp $ */
     1/* $Id: relaywin.h,v 1.3 1999-12-02 15:22:05 achimha Exp $ */
    22
    33/*
     
    3636 *****************************************************************************/
    3737
     38/* these are the request types so we can interpret the messages and convert the results */
     39#define ASYNCREQUEST_SELECT 0
     40#define ASYNCREQUEST_GETHOSTBYNAME 1
     41
    3842typedef struct tagHwndMsgPair
    3943{
    4044  HWND  hwnd;  /* target window            */
    4145  ULONG ulMsg; /* the message code to send */
     46  ULONG ulRequestType; /* the type of request that this belongs to */
     47  PVOID pvUserData1; /* request specific data field */
     48  PVOID pvUserData2; /* request specific data field */
    4249} HWNDMSGPAIR, *PHWNDMSGPAIR;
    4350
     
    4653 *****************************************************************************/
    4754
    48 ULONG        RelayAlloc     (HWND  hwnd, ULONG ulMsg);
     55ULONG RelayAlloc(HWND hwnd, ULONG ulMsg, ULONG ulRequestType,
     56                 PVOID pvUserData1 = 0, PVOID pvUserData2 = 0);
    4957ULONG        RelayFree      (ULONG ulID);
    5058ULONG        RelayFreeByHwnd(HWND  hwnd);
  • trunk/src/wsock32/new/wsock32.cpp

    r1934 r1940  
    1 /* $Id: wsock32.cpp,v 1.8 1999-12-02 07:58:54 phaller Exp $ */
     1/* $Id: wsock32.cpp,v 1.9 1999-12-02 15:22:05 achimha Exp $ */
    22
    33/*
     
    6363static WSOCKTHREADDATA wstdFallthru; // for emergency only
    6464
     65static HWND hwndRelay; // handle to our relay window
    6566
    6667/*****************************************************************************
     
    12681269              int,buflen)
    12691270{
    1270   return(WSAAsyncGetHostByName(hWnd,
    1271                                wMsg,
    1272                                name,
    1273                                buf,
    1274                                buflen));
     1271  int   rc;
     1272  HWND  hwndOS2 = Win32ToOS2Handle(hWnd);
     1273  ULONG ulNewID;
     1274  char *OS2Hostent = (char*)malloc(MAXGETHOSTSTRUCT);
     1275
     1276  if (hwndRelay == NULL) // already initialized ?
     1277    hwndRelay = RelayInitialize(hwndOS2);
     1278
     1279  // TODO: Is this the original behaviour?
     1280  if ((name == NULL) || (buf == NULL))
     1281  {
     1282    // remove entry from list
     1283    RelayFreeByHwnd(hWnd);
     1284  }
     1285  else
     1286    // add entry to list, we need to store both our temp buffer and the apps buffer
     1287    ulNewID = RelayAlloc(hWnd, wMsg, ASYNCREQUEST_GETHOSTBYNAME, buf, OS2Hostent);
     1288
     1289  // call pmwsock function, will fill our temp buffer
     1290  rc = WSAAsyncGetHostByName(hwndRelay,
     1291                             ulNewID,
     1292                             name,
     1293                             OS2Hostent,
     1294                             buflen);
     1295
     1296  return rc;
    12751297}
    12761298
     
    13491371  ULONG ulNewID;
    13501372
    1351   static HWND hwndRelay; // handle to our relay window
    1352 
    13531373  if (hwndRelay == NULL) // already initialized ?
    13541374    hwndRelay = RelayInitialize(hwndOS2);
     
    13801400  else
    13811401    // add entry to list
    1382     ulNewID = RelayAlloc(hWnd, wMsg);
     1402    ulNewID = RelayAlloc(hWnd, wMsg, ASYNCREQUEST_SELECT);
    13831403
    13841404  rc = WSAAsyncSelect(s,
Note: See TracChangeset for help on using the changeset viewer.