Re: APC/socket fix (final?)

From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: "Claudio Natoli" <claudio(dot)natoli(at)memetrics(dot)com>, "Tom Lane " <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-patches(at)postgresql(dot)org>
Subject: Re: APC/socket fix (final?)
Date: 2004-03-26 18:56:41
Message-ID: 6BCB9D8A16AC4241919521715F4D8BCE171625@algol.sollentuna.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

>> Ugh. Is there a way we can insert a wrapper layer without
>modifying the
>> call sites? I'm thinking of some kind of macro hack, say
>> [snip]
>
>Sure. Think we've even done this before (also, prevents
>developers needing to remember to use pg_*).

Yup, it's done to redefine kill() to pqkill(). See include/port/win32.h.

>The reason I think it was avoided for select(), in preference
>for a thread
>to invoke the socket op during the signal/APC, was a fear that
>perhaps the
>Windows Sockets internals could get mashed. AFAICS, the
>discussion Magnus
>had with the Microsoft guys (and, from memory, those I've had
>with Magnus
>off-list) suggests this isn't true. If mashing the internals is still a
>possibility, then clearly the patch I've submitted might do
>more harm than
>good.
>
>(Magnus, can you confirm?)

Yes, it can be done (for select, so I guess for recv and send). It is
recommended that we do not do it that way, though.

There is also a third option, which I'm leaning more and more towards. I
was in that direction in the beginning, but turned away from it thinking
it would be too much work. Also, I was under the impression that we
would rather have some "workarounds checking errors etc" than
reimplement code. I'm now getting the idea that we'd rather have it the
other way around, assuming the code is in the port dir. Fair enough.

The third option is to redefine all these functions into our own, and
implement our own emulation layer. This means our own select(), send(),
recv() (more? I don't think so). And have these call the native winsock
APIs (WSAEventSelect(), WSASend(), WSARecv() etc). These functions are
designed to work in an APC environment.

This is going to be a bit more code that can go wrong, but it carries
the advatages that (1) it's win32 only code, and (2) the code will all
be in the port directory. We implement it along with the standard Unix
semantics, so the main code should not notice. Doing this, we can back
out the changes done so far (the thread fix, the errno fix).

It's the "sledgehammer fix", but I think it's probably time to bite the
bullet and do this one. This way, it's *not* a workaround. Any surprises
we end up with should be from our own code.

>If so, I'll submit a patch for select/recv/send over the
>weekend, which will
>also remove the recent fixes for pgstat.

If you think my suggestion above is not a good one then yes, we can do
this one. But I don't feel all that good about it (and specifically, I
have not had it confirmed about recv() and send() yet - have asked, but
not received a response yet).

If not, I'm going to get started on an implementation using the WSA
functions for you to check over :-)

//Magnus

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-03-26 19:11:27 Re: APC/socket fix (final?)
Previous Message Bruce Momjian 2004-03-26 18:52:44 Re: installdir patch for win32