[rabbitmq-discuss] rabbitmq-c thread-safe

Tony Garnock-Jones tonyg at lshift.net
Mon Nov 16 13:01:15 GMT 2009


Hi Theo,

Theo Schlossnagle wrote:
> The current tip of rabbit-mq has two issues:
> The first is that it declares many blank structures:
>  typedef struct foo { } foo_t;
> Many compilers don't allow this -- in fact, gcc is the only know I know of that does.  This should be changed to something like:
>  typedef struct foo { unsigned unused:1; } foo_t;

Yes, the code is gcc-specific. It uses some of the gcc extensions (e.g.
statement expressions) which make C less unpalatable. I don't know how
much effort it would be to avoid the gccisms in the code, and I have to
say I'm not particularly motivated to try...

It's a shame that other compilers don't let you have no-member structs;
it seems to me perfectly sensible. Glancing at the language standard,
however, I see that syntactically an empty struct is not permitted, and
semantically if no members are declared the behaviour is undefined :-(

> The second issue is that the library uses a global variable to track
> the reply state on the a connection making it not thread safe.  I've
> patched the tip, it is attached.

Would it work instead to put the amqp_rpc_reply variable in the
amqp_connection_state_t?

> Also, rabbitmq-c has been exposed for perl-lovers as Net::RabbitMQ on CPAN.

Awesome! Thank you very much :-)

Regards,
  Tony
-- 
 [][][] Tony Garnock-Jones     | Mob: +44 (0)7905 974 211
   [][] LShift Ltd             | Tel: +44 (0)20 7729 7060
 []  [] http://www.lshift.net/ | Email: tonyg at lshift.net




More information about the rabbitmq-discuss mailing list