Commit 82b6eedd authored by Joanne Hugé's avatar Joanne Hugé

Clean up the code

parent 97d2b26f
......@@ -43,7 +43,7 @@
static int process_socket_error_queue();
static void print_timestamps(struct msghdr *msg);
static void process_timestamps(int recvmsg_flags);
static void process_timestamps();
static int so_priority = 3;
static struct sock_txtime sk_txtime;
......@@ -170,15 +170,14 @@ void send_udp_packet(int use_etf, int use_timestamps, uint64_t txtime,
FD_SET(fd, &readfs);
res = select(fd + 1, &readfs, 0, NULL, NULL);
printf("select returned: %d, %s\n", res, res < 0 ? strerror(errno) : "success");
if (res > 0) {
if (FD_ISSET(fd, &readfs)) printf("ready for reading\n");
process_timestamps(MSG_ERRQUEUE);
}
if (res > 0)
process_timestamps();
else
fprintf(stderr, "select failed\n");
}
}
static void process_timestamps(int recvmsg_flags) {
static void process_timestamps() {
char data[256];
struct msghdr msg;
struct iovec entry;
......@@ -199,7 +198,7 @@ static void process_timestamps(int recvmsg_flags) {
msg.msg_control = &control;
msg.msg_controllen = sizeof(control);
if (recvmsg(fd, &msg, recvmsg_flags | MSG_DONTWAIT) == -1) {
if (recvmsg(fd, &msg, MSG_ERRQUEUE | MSG_DONTWAIT) == -1) {
fprintf(stderr, "recvmsg failed\n");
}
else {
......@@ -222,12 +221,16 @@ static void print_timestamps(struct msghdr *msg) {
break;
}
default:
#ifdef DEBUG
printf("type %d", cmsg->cmsg_type);
#endif
break;
}
break;
default:
#ifdef DEBUG
printf("level %d type %d", cmsg->cmsg_level, cmsg->cmsg_type);
#endif
break;
}
printf("\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment