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

Clean up the code

parent 97d2b26f
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
static int process_socket_error_queue(); static int process_socket_error_queue();
static void print_timestamps(struct msghdr *msg); static void print_timestamps(struct msghdr *msg);
static void process_timestamps(int recvmsg_flags); static void process_timestamps();
static int so_priority = 3; static int so_priority = 3;
static struct sock_txtime sk_txtime; static struct sock_txtime sk_txtime;
...@@ -170,15 +170,14 @@ void send_udp_packet(int use_etf, int use_timestamps, uint64_t txtime, ...@@ -170,15 +170,14 @@ void send_udp_packet(int use_etf, int use_timestamps, uint64_t txtime,
FD_SET(fd, &readfs); FD_SET(fd, &readfs);
res = select(fd + 1, &readfs, 0, NULL, NULL); res = select(fd + 1, &readfs, 0, NULL, NULL);
printf("select returned: %d, %s\n", res, res < 0 ? strerror(errno) : "success"); if (res > 0)
if (res > 0) { process_timestamps();
if (FD_ISSET(fd, &readfs)) printf("ready for reading\n"); else
process_timestamps(MSG_ERRQUEUE); fprintf(stderr, "select failed\n");
}
} }
} }
static void process_timestamps(int recvmsg_flags) { static void process_timestamps() {
char data[256]; char data[256];
struct msghdr msg; struct msghdr msg;
struct iovec entry; struct iovec entry;
...@@ -199,7 +198,7 @@ static void process_timestamps(int recvmsg_flags) { ...@@ -199,7 +198,7 @@ static void process_timestamps(int recvmsg_flags) {
msg.msg_control = &control; msg.msg_control = &control;
msg.msg_controllen = sizeof(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"); fprintf(stderr, "recvmsg failed\n");
} }
else { else {
...@@ -222,12 +221,16 @@ static void print_timestamps(struct msghdr *msg) { ...@@ -222,12 +221,16 @@ static void print_timestamps(struct msghdr *msg) {
break; break;
} }
default: default:
#ifdef DEBUG
printf("type %d", cmsg->cmsg_type); printf("type %d", cmsg->cmsg_type);
#endif
break; break;
} }
break; break;
default: default:
#ifdef DEBUG
printf("level %d type %d", cmsg->cmsg_level, cmsg->cmsg_type); printf("level %d type %d", cmsg->cmsg_level, cmsg->cmsg_type);
#endif
break; break;
} }
printf("\n"); 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