Skip to content

Commit

Permalink
Merge pull request #1062 from zhfeng/JBTM-2743
Browse files Browse the repository at this point in the history
JBTM-2743 Blacktie integration-tests TestTPCancel hang
  • Loading branch information
tomjenkinson committed Aug 31, 2016
2 parents bed239d + e4663d6 commit c3a16fd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
15 changes: 14 additions & 1 deletion blacktie/hybrid/src/main/cpp/HybridSocketEndpointQueue.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,20 @@ HybridSocketEndpointQueue::HybridSocketEndpointQueue(HybridSocketSessionImpl* se
this->addr = strdup(addr);
this->port = port;
this->socket = NULL;
apr_pollset_create(&this->pollset, 1, this->pool, 0);
#ifdef BROKEN_WSAPOLL
/* JBTM-2743
*
* APR 1.4.x switched to using WSAPoll() on Win32, but it does not
* properly handle errors on a non-blocking sockets (such as
* connecting to a server where no listener is active).
*
* http://social.msdn.microsoft.com/Forums/en/wsk/thread/18769abd-fca0-4d3c-9884-1a38ce27ae90
*/
apr_pollset_create_ex(&this->pollset, 1, this->pool, 0, APR_POLLSET_SELECT);
LOG4CXX_DEBUG(logger, (char*) "create the pollset with the select impl as it has the broken wsapoll");
#else
apr_pollset_create(&this->pollset, 1, this->pool, 0);
#endif
this->ctx = &this->queue_ctx;
ctx->sock = NULL;
ctx->sid = id;
Expand Down
11 changes: 11 additions & 0 deletions blacktie/hybrid/src/main/include/HybridSocketEndpointQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "apr_errno.h"
#include "apr_poll.h"
#include "apr_thread_cond.h"
#include "apr_version.h"
#include "apr.h"

#include "SocketServer.h"
Expand All @@ -39,6 +40,16 @@
class HybridSocketSessionImpl;
#define DEF_POLL_TIMEOUT (APR_USEC_PER_SEC * 3)

/**
* JBTM-2743 we're on WIN32, and APR is version 1.4.0+,
* then we have a broken WSAPoll() implementation.
*/
#if defined(APR_VERSION_AT_LEAST) && defined(WIN32)
#if APR_VERSION_AT_LEAST(1,4,0)
#define BROKEN_WSAPOLL
#endif
#endif

class BLACKTIE_HYBRID_DLL HybridSocketEndpointQueue: public virtual Destination {
public:
HybridSocketEndpointQueue(HybridSocketSessionImpl* session, apr_pool_t* pool, int id, const char* addr, int port, void(*messagesAvailableCallback)(int, bool));
Expand Down

0 comments on commit c3a16fd

Please sign in to comment.