2018-04-02 01:39:08 +02:00
|
|
|
#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;
|
|
|
|
};
|
2018-04-02 10:11:25 +02:00
|
|
|
sem_post(&conn->q_sem);
|
2018-04-02 01:39:08 +02:00
|
|
|
return 0;
|
|
|
|
}
|