Changeset View
Changeset View
Standalone View
Standalone View
sbin/ggate/ggatec/ggatec.c
Show All 29 Lines | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <stdint.h> | #include <stdint.h> | ||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <ctype.h> | #include <ctype.h> | ||||
#include <inttypes.h> | |||||
#include <libgen.h> | #include <libgen.h> | ||||
#include <pthread.h> | #include <pthread.h> | ||||
#include <signal.h> | #include <signal.h> | ||||
#include <err.h> | #include <err.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <assert.h> | #include <assert.h> | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | if (hdr.gh_cmd == GGATE_CMD_WRITE) { | ||||
if (reconnect) | if (reconnect) | ||||
break; | break; | ||||
if (data != ggio.gctl_length) { | if (data != ggio.gctl_length) { | ||||
g_gate_log(LOG_ERR, "Lost connection 2 (%zd != %zd).", data, (ssize_t)ggio.gctl_length); | g_gate_log(LOG_ERR, "Lost connection 2 (%zd != %zd).", data, (ssize_t)ggio.gctl_length); | ||||
reconnect = 1; | reconnect = 1; | ||||
pthread_kill(recvtd, SIGUSR1); | pthread_kill(recvtd, SIGUSR1); | ||||
break; | break; | ||||
} | } | ||||
g_gate_log(LOG_DEBUG, "Sent %zd bytes (offset=%llu, " | g_gate_log(LOG_DEBUG, "Sent %zd bytes (offset=%" | ||||
"size=%u).", data, hdr.gh_offset, hdr.gh_length); | PRIu64 ", size=%" PRIu32 ").", data, hdr.gh_offset, | ||||
hdr.gh_length); | |||||
} | } | ||||
} | } | ||||
g_gate_log(LOG_DEBUG, "%s: Died.", __func__); | g_gate_log(LOG_DEBUG, "%s: Died.", __func__); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
static void * | static void * | ||||
recv_thread(void *arg __unused) | recv_thread(void *arg __unused) | ||||
Show All 37 Lines | if (ggio.gctl_error == 0 && ggio.gctl_cmd == GGATE_CMD_READ) { | ||||
break; | break; | ||||
g_gate_log(LOG_DEBUG, "Received data packet."); | g_gate_log(LOG_DEBUG, "Received data packet."); | ||||
if (data != ggio.gctl_length) { | if (data != ggio.gctl_length) { | ||||
g_gate_log(LOG_ERR, "Lost connection 4."); | g_gate_log(LOG_ERR, "Lost connection 4."); | ||||
reconnect = 1; | reconnect = 1; | ||||
pthread_kill(sendtd, SIGUSR1); | pthread_kill(sendtd, SIGUSR1); | ||||
break; | break; | ||||
} | } | ||||
g_gate_log(LOG_DEBUG, "Received %d bytes (offset=%ju, " | g_gate_log(LOG_DEBUG, "Received %d bytes (offset=%" | ||||
"size=%zu).", data, (uintmax_t)hdr.gh_offset, | PRIu64 ", size=%" PRIu32 ").", data, hdr.gh_offset, | ||||
(size_t)hdr.gh_length); | hdr.gh_length); | ||||
} | } | ||||
g_gate_ioctl(G_GATE_CMD_DONE, &ggio); | g_gate_ioctl(G_GATE_CMD_DONE, &ggio); | ||||
} | } | ||||
g_gate_log(LOG_DEBUG, "%s: Died.", __func__); | g_gate_log(LOG_DEBUG, "%s: Died.", __func__); | ||||
pthread_exit(NULL); | pthread_exit(NULL); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 403 Lines • Show Last 20 Lines |