Block Sock Block

WinHttpGetProxyForUrl also blocks.  This is despite the documentation saying that it won’t if you close the handle during it’s operation.  (Let’s face it, Microsoft programmers often have a very loose sense of the meaning of block, what’s a minute or two.)  Anyway, this called for a generic class for blocking things (see previous post re gethostbyname and getaddrinfo blocking).  Anyway, the class (as before Thread is a pretty basic personal thread class):

class CAbortableAction : public Thread
    CAbortableAction() : m_abort(CreateEvent(0,TRUE,FALSE,0),0,CloseHandle) {}
    virtual void AbortAction() {SetEvent(m_abort);}
    virtual bool StartAction()
            return false;
        HANDLE handles[] = {ThreadHandle(),m_abort};
        return (
    virtual void DoAction() = 0;
    bool IsAborted() { return EventHandle(m_abort).IsSet();}
    auto_HANDLE m_abort;
    DWORD ThreadProc() {DoAction();return 0;}


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s