Re: APC/socket fix (final?) - Mailing list pgsql-patches
From | Magnus Hagander |
---|---|
Subject | Re: APC/socket fix (final?) |
Date | |
Msg-id | 6BCB9D8A16AC4241919521715F4D8BCE171625@algol.sollentuna.se Whole thread Raw |
In response to | APC/socket fix (final?) (Claudio Natoli <claudio.natoli@memetrics.com>) |
Responses |
Re: APC/socket fix (final?)
|
List | 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
pgsql-patches by date: