mswsock:Implement 3 functions by calling through SIO_GET_EXTENSION_FUNCTION_POINTER (try 3)

Alexandre Julliard julliard at winehq.org
Tue Jul 8 05:09:33 CDT 2008


Jon Griffiths <jon_p_griffiths at yahoo.com> writes:

> +BOOL WINAPI AcceptEx(SOCKET listener, SOCKET acceptor, PVOID dest, DWORD dest_len,
> +                     DWORD local_addr_len, DWORD rem_addr_len, LPDWORD received,
> +                     LPOVERLAPPED overlapped)
>  {
> -    FIXME("(listen=%ld, accept=%ld, %p, %d, %d, %d, %p, %p), not implemented\n",
> -	sListenSocket,sAcceptSocket,lpOutputBuffer,dwReceiveDataLength,
> -	dwLocalAddressLength,dwRemoteAddressLength,lpdwBytesReceived,lpOverlapped
> -    );
> +    EnterCriticalSection(&MSWSOCK_CritSect);
> +    if (!acceptex_fn)
> +    {
> +        /* Get pointers to the ws2_32 implementations.
> +         * NOTE: This assumes that ws2_32 contains only one implementation
> +         * of these functions, i.e. that you cannot get different functions
> +         * back by passing another socket in. If that ever changes, we'll need
> +         * to think about associating the functions with the socket and
> +         * exposing that information to this dll somehow.
> +         */
> +        const GUID acceptex_guid = WSAID_ACCEPTEX;
> +        const GUID acceptexsockaddrs_guid = WSAID_GETACCEPTEXSOCKADDRS;
> +        DWORD len;
> +        WSAIoctl(acceptor, SIO_GET_EXTENSION_FUNCTION_POINTER,
> +                 (void*)&acceptex_guid, sizeof(acceptex_guid),
> +                 &acceptex_fn, sizeof(acceptex_fn), &len, NULL, NULL);
> +        WSAIoctl(acceptor, SIO_GET_EXTENSION_FUNCTION_POINTER,
> +                 (void*)&acceptexsockaddrs_guid, sizeof(acceptexsockaddrs_guid),
> +                 &acceptexsockaddrs_fn, sizeof(acceptexsockaddrs_fn), &len, NULL, NULL);
> +    }
> +    LeaveCriticalSection(&MSWSOCK_CritSect);

You don't need a crit section since you assume that the pointers are
always the same, but you do need to fetch them into local variables and
check for error before setting the global ones.

> +    static const GUID guid = WSAID_TRANSMITFILE;
> +    LPFN_TRANSMITFILE fn;
> +    DWORD len;
>  
> -    return FALSE;
> +    /* Use the implementation provided by ws2_32 */
> +    if (WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER,
> +                 (void*)&guid, sizeof(guid), &fn, sizeof(fn), &len, NULL, NULL))
> +        return FALSE;
> +
> +    return fn(s, file, total_len, chunk_len, overlapped, buffers, flags);

You should store this one globally too, no need to do the ioctl on every
call.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list