Fix enumeration of fstab-entries in gkrellmd (fstab entries were only sent to a client if fstab was marked as modified, unfortunately this is never the case on win32). Fixes #3.

Remove parsing of "--debug-level" in get_args(), it is already parsed in parse_config()
Make "-d" commandline option the short version for "--detach" only. Before it was also used as a short version for "--debug-level"
This commit is contained in:
Stefan Gehn 2010-06-13 13:40:20 +00:00
parent 7e86c76f32
commit 07551c6fe9
3 changed files with 44 additions and 7 deletions

View File

@ -568,7 +568,11 @@ remove_client(gint fd)
if (client->fd == fd)
{
g_message(_("Removing client %s\n"), client->hostname);
#if defined(WIN32)
closesocket(fd);
#else
close(fd);
#endif
g_free(client->hostname);
g_free(client);
gkrellmd_client_list = g_list_remove(gkrellmd_client_list, client);
@ -633,7 +637,11 @@ parse_config(gchar *config, gchar *arg)
else if (!strcmp(config, "net-timer"))
_GK.net_timer = g_strdup(arg);
else if (!strcmp(config, "debug-level") || !strcmp(config, "debug"))
{
_GK.debug_level = (gint) strtoul(arg, NULL, 0);
if (_GK.debug_level > 0)
g_print("Set debug-level to 0x%x\n", _GK.debug_level);
}
else if (!strcmp(config, "logfile"))
gkrellm_log_set_filename(arg);
#if !defined(WIN32)
@ -825,7 +833,7 @@ usage(void)
g_print( " --logfile path Enable logging to a file\n");
g_print( " --syslog Enable logging to syslog\n");
g_print(_(" -V, --verbose increases the verbosity of gkrellmd\n"));
g_print(_(" -d, --debug-level n Turn debugging on for selective code sections.\n"));
g_print(_(" -debug, --debug-level n Turn debugging on for selective code sections.\n"));
#else
@ -854,6 +862,7 @@ usage(void)
g_print(_(" -V, --verbose increases the verbosity of gkrellmd\n"));
g_print(_(" -h, --help display this help and exit\n"));
g_print(_(" -v, --version output version information and exit\n"));
g_print(_(" -debug, --debug-level n Turn debugging on for selective code sections.\n"));
#endif
}
@ -884,8 +893,6 @@ get_args(gint argc, gchar **argv)
else if (!strcmp(s, "without-libsensors"))
_GK.without_libsensors = TRUE;
#endif /* !WIN32 */
else if ((!strcmp(s, "debug-level") || !strcmp(s, "d")) && i < argc - 1)
_GK.debug_level = (gint) strtoul(argv[++i], NULL, 0);
else if ( i < argc
&& ((r = parse_config(s, (i < argc - 1) ? argv[i+1] : NULL)) >= 0)
)
@ -984,7 +991,11 @@ socksetup(int af)
if (setsockopt(*s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
{
g_warning("gkrellmd: setsockopt (SO_REUSEADDR) failed\n");
#if defined(WIN32)
closesocket(*s);
#else
close(*s);
#endif
continue;
}
}
@ -997,14 +1008,22 @@ socksetup(int af)
if (setsockopt(*s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0)
{
g_warning("gkrellmd: setsockopt (IPV6_V6ONLY) failed\n");
#if defined(WIN32)
closesocket(*s);
#else
close(*s);
#endif
continue;
}
}
#endif
if (bind(*s, r->ai_addr, r->ai_addrlen) < 0)
{
close(*s);
#if defined(WIN32)
closesocket(*s);
#else
close(*s);
#endif
continue;
}
(*socks)++;
@ -1196,7 +1215,11 @@ gkrellmd_run(gint argc, gchar **argv)
{
if (listen(_GK.server_fd[i], 5) == -1)
{
close(_GK.server_fd[i]);
#if defined(WIN32)
closesocket(_GK.server_fd[i]);
#else
close(_GK.server_fd[i]);
#endif
continue;
}
++listen_fds;
@ -1284,7 +1307,11 @@ gkrellmd_run(gint argc, gchar **argv)
(struct sockaddr *)&client_addr, addr_len);
if (!client)
{
close(client_fd);
#if defined(WIN32)
closesocket(client_fd);
#else
close(client_fd);
#endif
continue;
}
FD_SET(client_fd, &read_fds);

View File

@ -92,6 +92,7 @@ gkrellmd_serve_data(GkrellmdMonitor *mon, gchar *line)
if (mp->serve_name)
{
snprintf(buf, sizeof(buf), "<%s>\n", mp->serve_name);
gkrellm_debug(DEBUG_SERVER, "%s", buf);
mp->serve_gstring = g_string_append(mp->serve_gstring, buf);
mp->serve_name_sent = TRUE;
}
@ -102,6 +103,7 @@ gkrellmd_serve_data(GkrellmdMonitor *mon, gchar *line)
return;
}
}
gkrellm_debug(DEBUG_SERVER,"%s", line);
mp->serve_gstring = g_string_append(mp->serve_gstring, line);
}
@ -1510,7 +1512,7 @@ update_fs(GkrellmdMonitor *mon, gboolean first_update)
#endif
}
}
if (gkrellm_sys_fs_fstab_modified())
if (first_update || gkrellm_sys_fs_fstab_modified())
refresh_fstab_list();
gkrellmd_need_serve(mon);
@ -1533,6 +1535,8 @@ serve_fs_data(GkrellmdMonitor *mon, gboolean first_serve)
snprintf(buf, sizeof(buf), "%s %s %s %ld %ld %ld %ld\n",
m->directory, m->device, m->type,
m->blocks, m->bavail, m->bfree, m->bsize);
/*gkrellm_debug(DEBUG_SERVER,
"Adding mount-line for %s to serve-data\n", m->directory);*/
gkrellmd_serve_data(mon, buf);
}
}
@ -1547,6 +1551,8 @@ serve_fs_data(GkrellmdMonitor *mon, gboolean first_serve)
snprintf(buf, sizeof(buf), "%s %s %ld %ld %ld %ld\n",
m->directory, m->device,
m->blocks, m->bavail, m->bfree, m->bsize);
/*gkrellm_debug(DEBUG_SERVER,
"Updating fs %s in serve-data\n", m->directory);*/
gkrellmd_serve_data(mon, buf);
}
}
@ -1559,6 +1565,8 @@ serve_fs_data(GkrellmdMonitor *mon, gboolean first_serve)
m = (Mount *) list->data;
snprintf(buf, sizeof(buf), "%s %s %s\n",
m->directory, m->device, m->type);
/*gkrellm_debug(DEBUG_SERVER,
"Adding fstab-line for %s to serve-data\n", m->directory);*/
gkrellmd_serve_data(mon, buf);
}
}

View File

@ -1949,6 +1949,8 @@ gboolean gkrellm_sys_battery_init()
gboolean gkrellm_sys_fs_fstab_modified(void)
{
/* TODO: determine changes in available volumes on win32 using
FindFirstVolume(), FindNextVolume() etc. */
return FALSE;
}