Re: MemPool.c's

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Wed, 17 Apr 2002 00:00:19 +0200

Ah, makes sense.

From what I can understand this should work on OS/2 as well.. at least
the same functions are documented as available in the Watcom C library
on all OS derivates in the dos/windows world..

Function: _get_osfhandle
Availability: DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32,
Netware

But 2K filedescriptors is a noticeable limit. Any chance of increasing
this?

Regards
Henrik

Guido Serassio wrote:
>
> Hi Henrik,
>
> Il 22.04 16/04/2002 Henrik Nordstrom ha scritto:
> >Guido Serassio wrote:
> >
> > > Sorry, but I just removed this from the nt source code ....
> >
> >Just curious, but how do you now deal with the difference in file and socket
> >filedescriptors, and their possible numeric overlap?
> >
> >(too lazy to dig into the nt branch to find out..)
>
> The difference between Files ant Sockets it's present only at the MSVCRT
> level. For NT all are simply handles to something.
> So, using _get_osfhandle(), _open_osfhandle() and _free_osfhnd() MSVCRT
> functions that works on real OS handles remapped on MSVCRT FD will make the
> magic:
>
> #define socket(f,t,p) \
> (INVALID_SOCKET == ((SOCKET)ws32_result = socket(f,t,p)) ? \
> ((WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1),
> -1) : \
> (SOCKET)_open_osfhandle(ws32_result,0))
>
> #define closesocket(s) \
> { \
> (SOCKET_ERROR == closesocket(_get_osfhandle(s)) ? \
> (errno = WSAGetLastError()), -1 : 0); \
> _free_osfhnd(s); \
> _osfile(s) = 0; \
> }
>
> #define select(n,r,w,e,t) \
> (SOCKET_ERROR == (ws32_result = select(n,r,w,e,t)) ? \
> (errno = WSAGetLastError()), -1 : ws32_result)
>
> And so on.
> In this manner Unix Socket code compiles unchanged at 99% and the major
> problem that socket handle ordinal returned from socket() are not reused
> and always grows without sequentiality is resolved.
>
> The only limit is that FD count limit is hard coded to 2048.
>
> For this work, we must thanks Andrey Shorin.
>
> Regards
>
> Guido
>
> >Regards
> >Henrik
>
> -
> =======================================================
> Serassio Guido
> Via Albenga, 11/4 10134 - Torino - ITALY
> E-mail: guido.serassio@serassio.it
> WWW: http://www.serassio.it
Received on Tue Apr 16 2002 - 16:04:08 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:15:11 MST