# HG changeset patch # User renatofilho # Date 1175028155 -3600 # Node ID 5ef4452c42ccd6360cc7fb7b989a108e6f429614 # Parent 771f91aa9d5d6584afa00ccf7eab4c3088154e12 [svn r469] bug fix diff -r 771f91aa9d5d -r 5ef4452c42cc gmyth/src/gmyth_jobqueue.c --- a/gmyth/src/gmyth_jobqueue.c Tue Mar 27 21:31:34 2007 +0100 +++ b/gmyth/src/gmyth_jobqueue.c Tue Mar 27 21:42:35 2007 +0100 @@ -46,10 +46,10 @@ if (gmyth_socket_connect_to_backend (socket, gmyth_backend_info_get_hostname (backend_info), gmyth_backend_info_get_port (backend_info), TRUE) == TRUE) { - g_debug ("Backend socket connection success"); + gmyth_debug ("Backend socket connection success"); return socket; } else { - g_debug ("Connection failed"); + gmyth_debug ("Connection failed"); return NULL; } } @@ -109,7 +109,7 @@ if (g_ascii_strcasecmp(ret, value) == 0) { return TRUE; } else { - g_debug("JobQueue Error: %s", ret); + gmyth_debug("JobQueue Error: %s", ret); return FALSE; } } @@ -155,7 +155,7 @@ g_free (ret); } else { - g_debug("JobQueue Connection Failed"); + gmyth_debug("JobQueue Connection Failed"); } return res; @@ -188,7 +188,7 @@ g_free(ret); } else { - g_debug("JobQueue Connection Failed"); + gmyth_debug("JobQueue Connection Failed"); } return res; diff -r 771f91aa9d5d -r 5ef4452c42cc gmyth/src/gmyth_livetv.c --- a/gmyth/src/gmyth_livetv.c Tue Mar 27 21:31:34 2007 +0100 +++ b/gmyth/src/gmyth_livetv.c Tue Mar 27 21:42:35 2007 +0100 @@ -470,7 +470,7 @@ } /* if - changes the channel number */ - sleep (6); /* FIXME: this is evil (tpm) */ + //sleep (1); /* FIXME: this is evil (tpm) */ } /* DEBUG message */ diff -r 771f91aa9d5d -r 5ef4452c42cc gmyth/src/gmyth_monitor_handler.c --- a/gmyth/src/gmyth_monitor_handler.c Tue Mar 27 21:31:34 2007 +0100 +++ b/gmyth/src/gmyth_monitor_handler.c Tue Mar 27 21:42:35 2007 +0100 @@ -145,63 +145,49 @@ gmyth_monitor_handler_dispose (GObject *object) { GMythMonitorHandler *monitor = GMYTH_MONITOR_HANDLER (object); - GSource* source = NULL; - //GMainContext* context = g_main_context_default(); - - gmyth_monitor_handler_close(monitor); + gmyth_monitor_handler_close(monitor); monitor->allow_msgs_listener = FALSE; - if ( monitor->sid_io_watch != -1 ) + if (monitor->sid_io_watch != -1) { - //g_main_context_acquire( context ); - - source = g_main_context_find_source_by_id( NULL, - monitor->sid_io_watch ); - - if ( source != NULL ) - { - g_source_destroy( source ); - } - - //g_main_context_release( context ); - + g_source_remove (monitor->sid_io_watch); } - /* mutex to control access to the event socket consumer thread */ - if ( monitor->mutex != NULL ) - { - g_mutex_free( monitor->mutex ); - monitor->mutex = NULL; - } + /* mutex to control access to the event socket consumer thread */ + if ( monitor->mutex != NULL ) + { + g_mutex_free( monitor->mutex ); + monitor->mutex = NULL; + } - if ( monitor->event_sock != NULL ) - { - g_object_unref( monitor->event_sock ); - monitor->event_sock = NULL; - } + if ( monitor->event_sock != NULL ) + { + g_object_unref( monitor->event_sock ); + monitor->event_sock = NULL; + } - if ( monitor->hostname != NULL ) - { - g_free( monitor->hostname ); - monitor->hostname = NULL; - } + if ( monitor->hostname != NULL ) + { + g_free( monitor->hostname ); + monitor->hostname = NULL; + } - if ( monitor->backend_msgs != NULL ) - { - g_hash_table_destroy ( monitor->backend_msgs ); - monitor->backend_msgs = NULL; - } + if ( monitor->backend_msgs != NULL ) + { + g_hash_table_destroy ( monitor->backend_msgs ); + monitor->backend_msgs = NULL; + } - /* - if ( io_watcher_cond != NULL ) - { - g_cond_free( io_watcher_cond ); - io_watcher_cond = NULL; - } - */ + /* + if ( io_watcher_cond != NULL ) + { + g_cond_free( io_watcher_cond ); + io_watcher_cond = NULL; + } + */ - G_OBJECT_CLASS (gmyth_monitor_handler_parent_class)->dispose (object); + G_OBJECT_CLASS (gmyth_monitor_handler_parent_class)->dispose (object); } static void @@ -238,11 +224,11 @@ myth_control_acquire_context( GMythMonitorHandler *monitor, gboolean do_wait ) { - gboolean ret = TRUE; + gboolean ret = TRUE; - g_mutex_lock( monitor->mutex ); + g_mutex_lock( monitor->mutex ); - return ret; + return ret; } @@ -259,10 +245,9 @@ gboolean ret = TRUE; - g_mutex_unlock( monitor->mutex ); + g_mutex_unlock( monitor->mutex ); - return ret; - + return ret; } void @@ -310,13 +295,13 @@ monitor->hostname = NULL; } - monitor->hostname = g_strdup( hostname ); + monitor->hostname = g_strdup (hostname); monitor->port = port; gmyth_debug ("Monitor event socket --- hostname: %s, port %d\n", monitor->hostname, monitor->port); /* configure the event socket */ - if ( NULL == monitor->event_sock ) { + if ( NULL == monitor->event_sock) { if (!gmyth_connect_to_backend_monitor (monitor)) { gmyth_debug( "Connection to backend failed (Event Socket)." ); ret = FALSE; @@ -355,7 +340,7 @@ strstr( back_msg->str, "BACKEND" ) != NULL ) { gmyth_debug( "MONITOR HANDLER - Received backend message = %s", back_msg->str ); - *back_msg_action = gmyth_string_list_get_char_array( strlist, 1 ); + *back_msg_action = gmyth_string_list_get_char_array( strlist, 1 ); if ( back_msg_action != NULL ) { @@ -501,7 +486,7 @@ strlist = NULL; } - io_cond = g_io_channel_get_buffer_condition( io_channel ); + io_cond = g_io_channel_get_buffer_condition (io_channel); } while ( recv <= 0 && ( ( io_cond & G_IO_HUP ) == 0 ) ); @@ -564,7 +549,7 @@ monitor->sid_io_watch = -1; - monitor->sid_io_watch = g_io_add_watch( channel, G_IO_IN | G_IO_HUP, + monitor->sid_io_watch = g_io_add_watch (channel, G_IO_IN | G_IO_HUP, (GIOFunc)gmyth_monitor_handler_listener, monitor ); } else { ret = FALSE; @@ -593,20 +578,20 @@ gboolean gmyth_monitor_handler_start (GMythMonitorHandler *monitor) { - gboolean ret = TRUE; + gboolean ret = TRUE; - ret = gmyth_monitor_handler_setup( monitor, monitor->event_sock->sd_io_ch ); - if ( ret ) { - gmyth_debug ( "\n[%s]\tOK! Starting listener on the MONITOR event socket...[thread location = %p]\n", + ret = gmyth_monitor_handler_setup( monitor, monitor->event_sock->sd_io_ch ); + if ( ret ) { + gmyth_debug ( "\n[%s]\tOK! Starting listener on the MONITOR event socket...[thread location = %p]\n", __FUNCTION__, g_thread_self( ) ); - ret = TRUE; - } else { - gmyth_debug ( "\n[%s]\tERROR! Coudn't start listener on the MONITOR event socket...[thread location = %p]\n", + ret = TRUE; + } else { + gmyth_debug ( "\n[%s]\tERROR! Coudn't start listener on the MONITOR event socket...[thread location = %p]\n", __FUNCTION__, g_thread_self( ) ); - ret = FALSE; - } + ret = FALSE; + } - gmyth_debug( "[%s] Watch listener function over the IO control channel? %s!!!\n", + gmyth_debug( "[%s] Watch listener function over the IO control channel? %s!!!\n", __FUNCTION__, ( ret == TRUE ? "YES" : "NO" ) ); return ret; diff -r 771f91aa9d5d -r 5ef4452c42cc gmyth/src/gmyth_query.c --- a/gmyth/src/gmyth_query.c Tue Mar 27 21:31:34 2007 +0100 +++ b/gmyth/src/gmyth_query.c Tue Mar 27 21:42:35 2007 +0100 @@ -154,7 +154,7 @@ return FALSE; } - g_debug ("[%s] Connection to Mysql server succeeded! (host = %s, user = %s, "\ + gmyth_debug ("[%s] Connection to Mysql server succeeded! (host = %s, user = %s, "\ "password = %s, db name = %s)", __FUNCTION__, gmyth_query->backend_info->hostname, gmyth_query->backend_info->username, @@ -175,7 +175,7 @@ assert(gmyth_query); /* TODO: Check how to return error */ - g_debug ("[%s] Closing gmyth_query->conn", __FUNCTION__); + gmyth_debug ("[%s] Closing gmyth_query->conn", __FUNCTION__); mysql_close (gmyth_query->conn); @@ -185,14 +185,14 @@ static void gmyth_query_print_error (MYSQL *conn, char *message) { - g_debug ("%s", message); + gmyth_debug ("%s", message); if (conn != NULL) { #if MYSQL_VERSION_ID >= 40101 - g_debug ("Error %u (%s): %s\n", + gmyth_debug ("Error %u (%s): %s\n", mysql_errno (conn), mysql_sqlstate(conn), mysql_error (conn)); #else - g_debug ("Error %u: %s\n", + gmyth_debug ("Error %u: %s\n", mysql_errno (conn), mysql_error (conn)); #endif } @@ -215,7 +215,7 @@ assert(gmyth_query); - g_debug ("[%s] Running mysql query %s", __FUNCTION__, stmt_str); + gmyth_debug ("[%s] Running mysql query %s", __FUNCTION__, stmt_str); if (gmyth_query == NULL) return NULL; @@ -231,7 +231,7 @@ if (res_set) { return res_set; } else if (mysql_field_count (gmyth_query->conn) == 0) { - g_debug ("%lu rows affected\n", + gmyth_debug ("%lu rows affected\n", (unsigned long) mysql_affected_rows (gmyth_query->conn)); } else { gmyth_query_print_error (gmyth_query->conn, "Could not retrieve result set"); diff -r 771f91aa9d5d -r 5ef4452c42cc gmyth/src/gmyth_socket.c --- a/gmyth/src/gmyth_socket.c Tue Mar 27 21:31:34 2007 +0100 +++ b/gmyth/src/gmyth_socket.c Tue Mar 27 21:42:35 2007 +0100 @@ -130,7 +130,7 @@ gmyth_debug ("Getting name resolution for: %s, %d\n", addr, port); if ( ( errorn = getaddrinfo(addr, portStr, &hints, addrInfo) ) != 0 ) { - g_debug( "[%s] Socket ERROR: %s\n", __FUNCTION__, gai_strerror(errorn) ); + gmyth_debug( "[%s] Socket ERROR: %s\n", __FUNCTION__, gai_strerror(errorn) ); } g_free (portStr); @@ -138,16 +138,18 @@ return errorn; } +/* static gint gmyth_socket_find_match_address_uri( GMythURI* uri, gchar *address ) { if ( g_ascii_strcasecmp( gmyth_uri_get_host( uri ), address ) == 0 ) { - //g_debug( "Found URI: %s !!!\n", rui_uri_getvalue(uri) ); + //gmyth_debug( "Found URI: %s !!!\n", rui_uri_getvalue(uri) ); return 0; } else { return -1; } } +*/ static const gchar *PATH_PROC_NET_DEV = "/proc/net/dev"; @@ -207,9 +209,11 @@ } + /** * Get only the local addresses from the primary interface */ +/* static gchar * gmyth_socket_get_primary_addr() { @@ -220,7 +224,7 @@ if ( interfs != NULL && ( g_list_length( interfs ) > 0 ) ) { - /* get the first occurrence (primary interface) */ + // get the first occurrence (primary interface) if_tmp = g_list_first( interfs ); if ( if_tmp != NULL ) @@ -233,6 +237,7 @@ return if_eth0; } +*/ /** This function retrieves the local hostname of the * client machine. @@ -246,7 +251,7 @@ gint res = gethostname (hname, 50); if (res == -1) { - g_debug ("Error while getting hostname"); + gmyth_debug ("Error while getting hostname"); return NULL; } @@ -274,7 +279,7 @@ if ( err == EADDRNOTAVAIL ) { - g_debug( "[%s] Address (%s) not available. (reason = %d)\n", __FUNCTION__, localhostname, err ); + gmyth_debug( "[%s] Address (%s) not available. (reason = %d)\n", __FUNCTION__, localhostname, err ); return str; } @@ -309,7 +314,7 @@ gchar *prim_addr = gmyth_socket_get_primary_addr(); if ( prim_addr != NULL ) { - g_debug("[%s] Could not determine the local alphanumerical hostname. Setting to %s\n", + gmyth_debug("[%s] Could not determine the local alphanumerical hostname. Setting to %s\n", __FUNCTION__, prim_addr ); str = g_string_new (prim_addr); @@ -394,14 +399,14 @@ saveflags = fcntl( fd, F_GETFL, 0 ); if( saveflags < 0 ) { - g_debug( "[%s] Problems when getting socket flags on fcntl.\n", __FUNCTION__ ); + gmyth_debug( "[%s] Problems when getting socket flags on fcntl.\n", __FUNCTION__ ); *err=errno; return -1; } /* Set non blocking */ if( fcntl( fd, F_SETFL, saveflags | O_NONBLOCK ) < 0) { - g_debug( "[%s] Problems when setting non-blocking using fcntl.\n", __FUNCTION__ ); + gmyth_debug( "[%s] Problems when setting non-blocking using fcntl.\n", __FUNCTION__ ); *err=errno; return -1; } @@ -412,7 +417,7 @@ /* restore flags */ if( fcntl( fd, F_SETFL, saveflags ) < 0) { - g_debug( "[%s] Problems when trying to restore flags with fcntl.\n", __FUNCTION__ ); + gmyth_debug( "[%s] Problems when trying to restore flags with fcntl.\n", __FUNCTION__ ); *err=errno; return -1; } @@ -420,7 +425,7 @@ /* return unless the connection was successful or the connect is still in progress. */ if( *err < 0 && back_err != EINPROGRESS) { - g_debug( "[%s] Connection unsucessfully (it is not in progress).\n", __FUNCTION__ ); + gmyth_debug( "[%s] Connection unsucessfully (it is not in progress).\n", __FUNCTION__ ); *err = errno; return -1; } @@ -430,14 +435,14 @@ *err = select( FD_SETSIZE, NULL, &fd_w, NULL, timeout); if ( *err < 0 ) { - g_debug( "[%s] Connection unsucessfull (timed out).\n", __FUNCTION__ ); + gmyth_debug( "[%s] Connection unsucessfull (timed out).\n", __FUNCTION__ ); *err=errno; return -1; } /* 0 means it timeout out & no fds changed */ if(*err==0) { - g_debug( "[%s] Connection unsucessfull [%d] - 0 means it timeout out & no fds changed\n", + gmyth_debug( "[%s] Connection unsucessfull [%d] - 0 means it timeout out & no fds changed\n", __FUNCTION__, *err ); close(fd); *err=ETIMEDOUT; @@ -449,14 +454,14 @@ *err=getsockopt( fd, SOL_SOCKET, SO_ERROR, &ret, (socklen_t *) &len); if( *err < 0 ) { - g_debug( "[%s] Connection unsucessfull.\n", __FUNCTION__ ); + gmyth_debug( "[%s] Connection unsucessfull.\n", __FUNCTION__ ); *err=errno; return -1; } /* ret=0 means success, otherwise it contains the errno */ if (ret) { - g_debug( "[%s] Connection unsucessfull - Couldn't connect to remote host!!!\n", __FUNCTION__ ); + gmyth_debug( "[%s] Connection unsucessfull - Couldn't connect to remote host!!!\n", __FUNCTION__ ); *err=ret; return -1; } @@ -535,13 +540,13 @@ if (gmyth_socket_try_connect (gmyth_socket->sd, (struct sockaddr *)addr_info0->ai_addr, addr_info0->ai_addrlen, timeout_val, &ret_code ) < 0 ) { - g_debug( "[%s] Error connecting to backend!\n", __FUNCTION__ ); + gmyth_debug( "[%s] Error connecting to backend!\n", __FUNCTION__ ); if (ret_code == ETIMEDOUT) - g_debug( "[%s]\tBackend host unreachable!\n", __FUNCTION__ ); + gmyth_debug( "[%s]\tBackend host unreachable!\n", __FUNCTION__ ); close (gmyth_socket->sd); gmyth_socket->sd = -1; - g_debug ("ERROR: %s\n", gai_strerror(ret_code)); + gmyth_debug ("ERROR: %s\n", gai_strerror(ret_code)); g_free (timeout_val); continue; } @@ -567,7 +572,7 @@ err = setsockopt(gmyth_socket->sd, SOL_SOCKET, SO_LINGER, ling, sizeof(struct linger)); if( err < 0 ) { - g_debug( "[%s] Setting connection unsucessfull.\n", __FUNCTION__ ); + gmyth_debug( "[%s] Setting connection unsucessfull.\n", __FUNCTION__ ); err=errno; ret = FALSE; goto cleanup; @@ -623,7 +628,7 @@ GIOCondition io_cond = g_io_channel_get_buffer_condition( gmyth_socket->sd_io_ch ); if ( ( io_cond & G_IO_IN ) == 0 ) { - g_debug ("[%s] IO channel is not able to send data!\n", __FUNCTION__); + gmyth_debug ("[%s] IO channel is not able to send data!\n", __FUNCTION__); ret = FALSE; } @@ -645,7 +650,7 @@ GIOCondition io_cond = g_io_channel_get_buffer_condition( gmyth_socket->sd_io_ch ); if ( ( ( io_cond & G_IO_OUT ) == 0 ) || ( ( io_cond & G_IO_HUP ) == 0 ) ) { - g_debug ("[%s] IO channel is not able to send data!\n", __FUNCTION__); + gmyth_debug ("[%s] IO channel is not able to send data!\n", __FUNCTION__); ret = FALSE; } @@ -674,7 +679,7 @@ g_return_val_if_fail( gmyth_socket->sd_io_ch != NULL, FALSE ); if( command == NULL || ( command->len <= 0 ) || command->str == NULL ) { - g_debug ("[%s] Invalid NULL command parameter!\n", __FUNCTION__); + gmyth_debug ("[%s] Invalid NULL command parameter!\n", __FUNCTION__); ret = FALSE; goto done; } @@ -693,10 +698,10 @@ if( (io_status == G_IO_STATUS_ERROR) || ( bytes_written <= 0 ) ) { - g_debug ("[%s] Error while writing to socket", __FUNCTION__); + gmyth_debug ("[%s] Error while writing to socket", __FUNCTION__); ret = FALSE; } else if ( bytes_written < command->len ) { - g_debug ("[%s] Not all data was written socket", __FUNCTION__); + gmyth_debug ("[%s] Not all data was written socket", __FUNCTION__); ret = FALSE; } @@ -704,7 +709,7 @@ if ( ( bytes_written != command->len ) || ( io_status == G_IO_STATUS_ERROR ) ) { - g_debug ("[%s] Some problem occurred when sending data to the socket\n", __FUNCTION__); + gmyth_debug ("[%s] Some problem occurred when sending data to the socket\n", __FUNCTION__); ret = TRUE; } @@ -712,7 +717,7 @@ g_mutex_unlock( gmyth_socket->mutex ); done: if ( error != NULL ) { - g_debug( "[%s] Error found reading data from IO channel: (%d, %s)\n", __FUNCTION__, error->code, error->message ); + gmyth_debug( "[%s] Error found reading data from IO channel: (%d, %s)\n", __FUNCTION__, error->code, error->message ); ret = FALSE; g_error_free( error ); } @@ -739,7 +744,7 @@ gboolean with_events) { if (!gmyth_socket_connect (gmyth_socket, hostname_backend, port)) { - g_debug ("[%s] Could not open socket to backend machine [%s]\n", __FUNCTION__, + gmyth_debug ("[%s] Could not open socket to backend machine [%s]\n", __FUNCTION__, hostname_backend ); return FALSE; } @@ -751,7 +756,7 @@ hostname = gmyth_socket_get_local_hostname(); if (hostname == NULL) { - g_debug ("Hostname not available, setting to n800frontend\n"); + gmyth_debug ("Hostname not available, setting to n800frontend\n"); hostname = g_string_new ("n800frontend"); } @@ -772,7 +777,7 @@ return TRUE; } else { - g_debug ("[%s] GMythSocket could not connect to the backend", __FUNCTION__); + gmyth_debug ("[%s] GMythSocket could not connect to the backend", __FUNCTION__); return FALSE; } } @@ -837,7 +842,7 @@ */ if (gmyth_socket->sd_io_ch != NULL) { - //g_io_channel_shutdown (gmyth_socket->sd_io_ch, TRUE, NULL); + g_io_channel_shutdown (gmyth_socket->sd_io_ch, TRUE, NULL); g_io_channel_unref (gmyth_socket->sd_io_ch); gmyth_socket->sd_io_ch = NULL; gmyth_socket->sd = -1; @@ -874,14 +879,14 @@ response = gmyth_socket_receive_response(gmyth_socket); if (response == NULL) { - g_debug ("[%s] Check protocol version error! Not answered!", __FUNCTION__); + gmyth_debug ("[%s] Check protocol version error! Not answered!", __FUNCTION__); res = FALSE; goto done; } res = g_str_has_prefix (response->str, "ACCEPT"); if (!res) { - g_debug ("[%s] Protocol version request error: %s", __FUNCTION__, response->str); + gmyth_debug ("[%s] Protocol version request error: %s", __FUNCTION__, response->str); /* get the version number returned by the REJECT message */ if ( ( res = g_str_has_prefix (response->str, "REJECT") ) == TRUE ) { gchar *new_version = NULL; @@ -998,7 +1003,7 @@ gmyth_debug ( "[%s] Bytes read = %d\n", __FUNCTION__, bytes_read ); if( (io_status == G_IO_STATUS_ERROR) || (bytes_read <= 0) ) { - g_debug ("[%s] Error in mythprotocol response from backend\n", __FUNCTION__); + gmyth_debug ("[%s] Error in mythprotocol response from backend\n", __FUNCTION__); str = NULL; //return NULL; } else if ( buffer != NULL && strlen(buffer) > 0 ) { @@ -1049,7 +1054,7 @@ str = g_string_new (buffer); if ( error != NULL ) { - g_debug( "[%s] Error found receiving response from the IO channel: (%d, %s)\n", + gmyth_debug( "[%s] Error found receiving response from the IO channel: (%d, %s)\n", __FUNCTION__, error->code, error->message ); str = NULL; g_error_free (error); diff -r 771f91aa9d5d -r 5ef4452c42cc gmyth/src/gmyth_transcoder.c --- a/gmyth/src/gmyth_transcoder.c Tue Mar 27 21:31:34 2007 +0100 +++ b/gmyth/src/gmyth_transcoder.c Tue Mar 27 21:42:35 2007 +0100 @@ -226,9 +226,9 @@ } trans->started = gmyth_jobqueue_add_job(trans, "JOB_TRANSCODE"); if (trans->started == FALSE) - g_debug ("Error while starting GMythTranscoder to file: %s", trans->output_filename); + gmyth_debug ("Error while starting GMythTranscoder to file: %s", trans->output_filename); } else { - g_debug ("GMythTransfer already started!"); + gmyth_debug ("GMythTransfer already started!"); } return trans->started;