Commit e651babd authored by Luca Boccassi's avatar Luca Boccassi

Problem: test_proxy_hwm uses an bool across threads

Solution: use atomics to avoid issues on non-x86 architectures
parent 02019d9f
...@@ -65,7 +65,7 @@ typedef struct ...@@ -65,7 +65,7 @@ typedef struct
const char *backend_endpoint; const char *backend_endpoint;
const char *control_endpoint; const char *control_endpoint;
bool subscriber_received_all; void *subscriber_received_all;
} proxy_hwm_cfg_t; } proxy_hwm_cfg_t;
static void lower_hwm (void *skt) static void lower_hwm (void *skt)
...@@ -184,8 +184,7 @@ static void subscriber_thread_main (void *pvoid) ...@@ -184,8 +184,7 @@ static void subscriber_thread_main (void *pvoid)
// INFORM THAT WE COMPLETED: // INFORM THAT WE COMPLETED:
cfg->subscriber_received_all = true; zmq_atomic_counter_inc (cfg->subscriber_received_all);
// CLEANUP // CLEANUP
...@@ -304,7 +303,7 @@ static void proxy_stats_asker_thread_main (void *pvoid) ...@@ -304,7 +303,7 @@ static void proxy_stats_asker_thread_main (void *pvoid)
// Start! // Start!
while (!cfg->subscriber_received_all) { while (!zmq_atomic_counter_value (cfg->subscriber_received_all)) {
#ifdef ZMQ_BUILD_DRAFT_API #ifdef ZMQ_BUILD_DRAFT_API
check_proxy_stats (control_req); check_proxy_stats (control_req);
#endif #endif
...@@ -399,7 +398,7 @@ int main (void) ...@@ -399,7 +398,7 @@ int main (void)
cfg.frontend_endpoint = "inproc://frontend"; cfg.frontend_endpoint = "inproc://frontend";
cfg.backend_endpoint = "inproc://backend"; cfg.backend_endpoint = "inproc://backend";
cfg.control_endpoint = "inproc://ctrl"; cfg.control_endpoint = "inproc://ctrl";
cfg.subscriber_received_all = false; cfg.subscriber_received_all = zmq_atomic_counter_new ();
void *proxy = zmq_threadstart (&proxy_thread_main, (void *) &cfg); void *proxy = zmq_threadstart (&proxy_thread_main, (void *) &cfg);
assert (proxy != 0); assert (proxy != 0);
...@@ -422,5 +421,7 @@ int main (void) ...@@ -422,5 +421,7 @@ int main (void)
int rc = zmq_ctx_term (context); int rc = zmq_ctx_term (context);
assert (rc == 0); assert (rc == 0);
zmq_atomic_counter_destroy (&cfg.subscriber_received_all);
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment