[Swan] misuse of pthread_t

D. Hugh Redelmeier hugh at mimosa.com
Sat Oct 5 08:37:06 EEST 2013


I'm no expert in pthreads -- I think that they were invented by the devil.  
In trying to understand their use in libreswan, I think that I've come 
across a number of problems.

Most of the problems are in programs/pluto/xauth.c.  There is a slight 
bleed into programs/pluto/state.c.

In POSIX Pthreads, pthread_t is an opaque type.  You cannot do many normal 
operations on it.

Several places in the code, it is assumed that values of this type can be 
compared using == or !=.  The right operation is pthread_equal.

Several places in the code, it is assumed that there is a null value of 
pthread_t, and that it is 0, and that it can be tested as if it were a 
boolean.  I don't think that there is a null value.


In programs/pluto/pluto_crypt.c, it is assumed that a pthread_t can be 
stored in a long int.  And that a value of -1 can be stored in it as an 
exceptional value.

Have I somehow misunderstood this?


More information about the Swan mailing list