3d51c17a9a
FossilOrigin-Name: 5cc472aaf15b6e5dfe9beb3241c11f51af85dc3a29d94fee47992cbaf794fde2
21 lines
361 B
C
21 lines
361 B
C
#include <errno.h>
|
|
#include <time.h>
|
|
|
|
#include "conn.h"
|
|
|
|
int conn_q_wait_packet(struct conn * conn, int seconds)
|
|
{
|
|
|
|
struct timespec timespec;
|
|
clock_gettime(CLOCK_REALTIME,×pec);
|
|
timespec.tv_sec+=seconds;
|
|
|
|
|
|
/* wait one second to get a packet */
|
|
if (sem_timedwait(&conn->q_sem,×pec)==-1){
|
|
return EAGAIN;
|
|
};
|
|
sem_post(&conn->q_sem);
|
|
return 0;
|
|
}
|