fde->events = 0;
#ifndef OS_WINDOWS
- fcntl(fd, F_SETFL, O_NONBLOCK);
+ int ret = fcntl(fd, F_SETFL, O_NONBLOCK);
+ if(ret == -1)
+ fprintf(stderr, "fail to set the file status flag\n");
if(fd >= max_select) {
max_select = fd + 1;
}
void wakeup_select_func(int _fd, unsigned ev, void *data) {
T_PACKET* t_packet = NULL;
- readx(_fd, &t_packet, sizeof(t_packet));
+ int length = readx(_fd, &t_packet, sizeof(t_packet));
+ if(length == -1) {
+ LOG_DEBUG("wakeup_select_func(): cannot read FD(%d) transport packet", _fd);
+ }
TRANSPORT* t= t_packet->t;
D("T(%s)\n", t->serial);
* then we need to reap it or else the next time we call this function,
* we'll get the previous completion and exit early
*/
- ioctl(h->node_fd, USBDEVFS_REAPURB, &context);
+ ret = ioctl(h->node_fd, USBDEVFS_REAPURB, &context);
+ if (ret < 0 && errno != EINVAL)
+ LOG_DEBUG("error reaping URB: %s\n", strerror(errno));
return rc;
}
static void _close_on_exec(int fd)
{
- fcntl( fd, F_SETFD, FD_CLOEXEC );
+ int ret = fcntl( fd, F_SETFD, FD_CLOEXEC );
+ if (ret == -1)
+ fprintf(stderr, "fail to set the file descriptor to be closed when the process executes another program\n");
}
static int _sdb_open( const char* pathname, int options )
static void _disable_tcp_nagle(int fd)
{
int on = 1;
- setsockopt( fd, IPPROTO_TCP, TCP_NODELAY, (void*)&on, sizeof(on) );
+ int ret = setsockopt( fd, IPPROTO_TCP, TCP_NODELAY, (void*)&on, sizeof(on) );
+ if (ret == -1)
+ fprintf(stderr, "fail to set level option of FD(%d)", fd);
}
static int _sdb_thread_create( sdb_thread_t *pthread, sdb_thread_func_t start, void* arg )
}
n = 1;
- setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n));
+ int ret = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n));
+ if (ret == -1)
+ fprintf(stderr, "fail to set level option of FD(%d)", s);
if(bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
sdb_close(s);