diff --git a/veejay-current/libsample/sampleadm.c b/veejay-current/libsample/sampleadm.c index 47949b54..6480eef8 100644 --- a/veejay-current/libsample/sampleadm.c +++ b/veejay-current/libsample/sampleadm.c @@ -2973,7 +2973,7 @@ void SaveCurrentPlaying( xmlNodePtr node, int id, int mode ) (const xmlChar*) buffer ); sprintf(buffer, "%d", mode ); xmlNewChild(node,NULL, (const xmlChar*) "PLAYING_MODE", - (const xmlChar*) mode ); + (const xmlChar*) buffer ); } diff --git a/veejay-current/libvjnet/vj-server.c b/veejay-current/libvjnet/vj-server.c index 6ffb73c1..7d969d51 100644 --- a/veejay-current/libvjnet/vj-server.c +++ b/veejay-current/libvjnet/vj-server.c @@ -298,9 +298,9 @@ int vj_server_send( vj_server *vje, int link_id, uint8_t *buf, int len ) total = sock_t_send_fd( Link[link_id]->handle, vje->send_size, buf, len, 0); if( total <= 0 ) { - veejay_msg(0,"Unable to send buffer to %s:%s", + veejay_msg(0,"Unable to send buffer to %s:%s ", (char*)(inet_ntoa(vje->remote.sin_addr)),strerror(errno)); - return 0; + return -1; } } else @@ -377,7 +377,7 @@ static int vj_server_send_frame_now( vj_server *vje, int link_id, uint8_t *buf, total = sock_t_send_fd( Link[link_id]->handle, vje->send_size, buf, len, 0); if( total <= 0 ) { - veejay_msg(0,"Unable to send buffer to %s:%s", + veejay_msg(0,"Unable to send buffer to %s: %s", (char*)(inet_ntoa(vje->remote.sin_addr)),strerror(errno)); return 0; } @@ -852,9 +852,14 @@ int vj_server_update( vj_server *vje, int id ) if(!vje->use_mcast) { n = recv( sock_fd, vje->recv_buf, RECV_SIZE, 0 ); - if( n <= 0) + if( n < 0) { - veejay_msg(VEEJAY_MSG_ERROR, "Receive error: %s", strerror(errno)); + // veejay_msg(VEEJAY_MSG_ERROR, "Receive error: %s", strerror(errno)); + return -1; + } + if( n == 0 ) + { + veejay_msg(VEEJAY_MSG_INFO ,"Connection closed by remote"); return -1; } } @@ -862,8 +867,10 @@ int vj_server_update( vj_server *vje, int id ) { vj_proto **proto = (vj_proto**) vje->protocol; n = mcast_recv( proto[0]->r, (void*) vje->recv_buf, RECV_SIZE ); - if( n <= 0 ) - return 0; + if( n < 0 ) + return -1; + if( n == 0 ) + return -1; } diff --git a/veejay-current/veejay/liblavplayvj.c b/veejay-current/veejay/liblavplayvj.c index 89d1e5dd..845d989b 100644 --- a/veejay-current/veejay/liblavplayvj.c +++ b/veejay-current/veejay/liblavplayvj.c @@ -191,6 +191,7 @@ struct mjpeg_params //#include #include +#include #ifdef HAVE_SDL #include #define MAX_SDL_OUT 2 @@ -1288,13 +1289,7 @@ void veejay_handle_signal(void *arg, int sig) else veejay_change_state( info, LAVPLAY_STATE_STOP ); - if( sig == SIGSEGV || sig == SIGFPE || sig == SIGBUS || sig == SIGPWR || sig == SIGABRT) - signal( sig, SIG_DFL ); - else - { - veejay_msg(VEEJAY_MSG_DEBUG, "Broken pipe"); - signal( sig, SIG_IGN ); - } + signal( sig, SIG_DFL ); } } } @@ -1321,6 +1316,11 @@ void vj_unlock(veejay_t *info) pthread_mutex_unlock(&(settings->valid_mutex)); } +static void donothing2(int sig) +{ + veejay_msg(0,"Catch signal %d",sig ); +} + static void *veejay_mjpeg_playback_thread(void *arg) { @@ -1331,6 +1331,18 @@ static void *veejay_mjpeg_playback_thread(void *arg) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + sigset_t mask; + struct sigaction act; + sigemptyset(&mask); + sigaddset( &mask, SIGPIPE ); + act.sa_handler = donothing2; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + + + pthread_sigmask( SIG_BLOCK, &mask, NULL ); + + /* schedule FIFO */ veejay_schedule_fifo( info, getpid()); diff --git a/veejay-current/veejay/veejay.c b/veejay-current/veejay/veejay.c index 65edfecf..840c2586 100644 --- a/veejay-current/veejay/veejay.c +++ b/veejay-current/veejay/veejay.c @@ -717,6 +717,9 @@ int main(int argc, char **argv) action.sa_handler = donothing; action.sa_mask = allsignals; action.sa_flags = SA_RESTART | SA_RESETHAND; + + signal( SIGPIPE, SIG_IGN ); + for( i = 1; i < NSIG; i ++ ) if( sigismember( &(settings->signal_set), i )) sigaction( i, &action, 0 ); diff --git a/veejay-current/veejay/vj-event.c b/veejay-current/veejay/vj-event.c index c1089177..6f19d410 100644 --- a/veejay-current/veejay/vj-event.c +++ b/veejay-current/veejay/vj-event.c @@ -284,7 +284,9 @@ veejay_msg(VEEJAY_MSG_INFO, "--------------------------------------------------- #define SEND_MSG(v,str)\ {\ -vj_server_send(v->vjs[VEEJAY_PORT_CMD], v->uc->current_link, str, strlen(str));\ +if(vj_server_send(v->vjs[VEEJAY_PORT_CMD], v->uc->current_link, str, strlen(str)) < 0) { \ + _vj_server_del_client( v->vjs[VEEJAY_PORT_CMD], v->uc->current_link); \ + _vj_server_del_client( v->vjs[VEEJAY_PORT_STA], v->uc->current_link);} \ } #define RAW_SEND_MSG(v,str,len)\ {\