Skip to content

Commit

Permalink
issue #205 MSG_NOSIGNAL not defined on apple machines, close socket o…
Browse files Browse the repository at this point in the history
…n error, declare MSG_NOSIGNAL and set SO_NOSIGPIPE
  • Loading branch information
game-stop committed Jul 8, 2019
1 parent bf17209 commit bdb76f7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions veejay-current/veejay-core/libvjnet/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
#include <sys/utsname.h>
#include <pthread.h>

#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif

struct host_list {
struct hostent hostent;
char h_addr_space[1024];
Expand Down Expand Up @@ -158,20 +162,32 @@ int sock_t_connect( vj_sock_t *s, char *host, int port )
{
veejay_msg(VEEJAY_MSG_ERROR, "Connection error with Veejay host %s:%d %s",
host, port, strerror(errno));
close( s->sock_fd );
return 0;
}
unsigned int tmp = sizeof(int);
if( getsockopt( s->sock_fd , SOL_SOCKET, SO_SNDBUF, (unsigned char*) &(s->send_size), &tmp) < 0 )
{
veejay_msg(VEEJAY_MSG_ERROR, "Unable to get buffer size for output: %s", strerror(errno));
close( s->sock_fd );
return 0;
}
if( getsockopt( s->sock_fd, SOL_SOCKET, SO_RCVBUF, (unsigned char*) &(s->recv_size), &tmp) < 0 )
{
veejay_msg(VEEJAY_MSG_ERROR, "Unable to get buffer size for input: %s", strerror(errno));
close( s->sock_fd );
return 0;
}

#ifdef SO_NOSIGPIPE
int opt = 1;
if( setsockopt( s->sock_fd, SOL_SOCKET, SO_NOSIGPIPE, (void*) &opt, sizeof(int)) < 0 ) {
veejay_msg(VEEJAY_MSG_ERROR, "Unable to set SO_NOSIGPIPE: %s", strerror(errno));
close(s->sock_fd);
return 0;
}
#endif

veejay_msg(VEEJAY_MSG_DEBUG, "Connected to host '%s' port %d, fd %d", host,port,s->sock_fd );
veejay_msg(VEEJAY_MSG_DEBUG, "Receive buffer size is %d bytes, send buffer size is %d bytes", s->recv_size, s->send_size );

Expand Down

0 comments on commit bdb76f7

Please sign in to comment.