You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
364 B
20 lines
364 B
#include <errno.h>
|
|
#include <time.h>
|
|
|
|
#include "conn.h"
|
|
|
|
int conn_q_wait_packet(struct cw_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;
|
|
}
|
|
|