[gamin] a couple patches needing review
- From: John McCutchan <ttb tentacle dhs org>
- To: gamin-list gnome org
- Subject: [gamin] a couple patches needing review
- Date: Thu, 21 Jul 2005 13:27:11 -0400
Yo Daniel, I'd like you to review the 2 patches attached.
pidname-patch: Same thing posted before. Just want to get your okay.
gamin-poll.patch: moves some poll debug under GAM_VERBOSE_POLL ifdef's.
Thanks
--
John McCutchan <ttb tentacle dhs org>
diff -u -r1.19 gam_connection.c
--- server/gam_connection.c 13 Jul 2005 16:53:54 -0000 1.19
+++ server/gam_connection.c 21 Jul 2005 16:32:01 -0000
@@ -27,6 +27,7 @@
GamConnState state; /* the state for the connection */
int fd; /* the file descriptor */
int pid; /* the PID of the remote process */
+ gchar *pidname; /* The name of the process */
GMainLoop *loop; /* the Glib loop used */
GIOChannel *source; /* the Glib I/O Channel used */
int request_len; /* how many bytes of request are valid */
@@ -90,6 +91,7 @@
g_io_channel_unref(conn->source);
gamConnList = g_list_remove(gamConnList, conn);
g_assert (!g_list_find(gamConnList, conn));
+ g_free(conn->pidname);
g_free(conn);
return (0);
@@ -178,6 +180,13 @@
return (conn->pid);
}
+gchar *
+gam_connection_get_pidname(GamConnDataPtr conn)
+{
+ g_assert (conn);
+ return conn->pidname;
+}
+
/**
* gam_connection_set_pid:
* @conn: a connection data structure.
@@ -191,6 +200,10 @@
gam_connection_set_pid(GamConnDataPtr conn, int pid)
{
g_assert(conn);
+#ifdef HAVE_LINUX
+ gchar *procname;
+ FILE *fp;
+#endif
if (conn->state != GAM_STATE_AUTH) {
GAM_DEBUG(DEBUG_INFO, "Connection in unexpected state: "
@@ -201,6 +214,33 @@
conn->state = GAM_STATE_OKAY;
conn->pid = pid;
+#ifdef HAVE_LINUX
+ procname = g_strdup_printf ("/proc/%d/cmdline", pid);
+ fp = fopen(procname, "r");
+ g_free (procname);
+ if (!fp) {
+ conn->pidname = g_strdup_printf ("%d", pid);
+ } else {
+ gchar *name = g_malloc (128);
+ int i = 0;
+ while (i < 128) {
+ int ch = fgetc (fp);
+
+ if (ch == EOF)
+ break;
+
+ name[i++] = ch;
+
+ if (ch == '\0')
+ break;
+ }
+ name[127] = '\0';
+ conn->pidname = g_strdup (name);
+ g_free (name);
+ }
+#else
+ conn->pidname = g_strdup_printf ("%d", pid);
+#endif
conn->listener = gam_listener_new(conn, pid);
if (conn->listener == NULL) {
GAM_DEBUG(DEBUG_INFO, "Failed to create listener\n");
@@ -276,8 +316,8 @@
type = req->type & 0xF;
options = req->type & 0xFFF0;
- GAM_DEBUG(DEBUG_INFO, "Request: from %d, seq %d, type %x options %x\n",
- conn->pid, req->seq, type, options);
+ GAM_DEBUG(DEBUG_INFO, "Request: from %s, seq %d, type %x options %x\n",
+ conn->pidname, req->seq, type, options);
if (req->pathlen >= MAXPATHLEN)
return (-1);
@@ -506,7 +546,7 @@
return (-1);
}
- GAM_DEBUG(DEBUG_INFO, "Event to %d : %d, %d, %s %s\n", conn->pid,
+ GAM_DEBUG(DEBUG_INFO, "Event to %s : %d, %d, %s %s\n", conn->pidname,
reqno, type, path, gam_event_to_string(event));
/*
* prepare the packet
@@ -521,7 +561,7 @@
memcpy(req.path, path, len);
ret = gam_client_conn_write(conn->source, conn->fd, (gpointer) &req, tlen);
if (!ret) {
- GAM_DEBUG(DEBUG_INFO, "Failed to send event to %d\n", conn->pid);
+ GAM_DEBUG(DEBUG_INFO, "Failed to send event to %s\n", conn->pidname);
return (-1);
}
return (0);
@@ -557,7 +597,7 @@
return (-1);
}
- GAM_DEBUG(DEBUG_INFO, "Event to %d: %d, %d, %s\n", conn->pid,
+ GAM_DEBUG(DEBUG_INFO, "Event to %s: %d, %d, %s\n", conn->pidname,
reqno, FAMAcknowledge, path);
/*
@@ -575,7 +615,7 @@
ret = gam_client_conn_write(conn->source, conn->fd, (gpointer) &req, tlen);
if (!ret) {
- GAM_DEBUG(DEBUG_INFO, "Failed to send event to %d\n", conn->pid);
+ GAM_DEBUG(DEBUG_INFO, "Failed to send event to %s\n", conn->pidname);
return (-1);
}
return (0);
@@ -661,8 +701,8 @@
break;
}
GAM_DEBUG(DEBUG_INFO,
- "Connection fd %d to pid %d: state %s, %d read\n",
- conn->fd, conn->pid, state, conn->request_len);
+ "Connection fd %d to %s: state %s, %d read\n",
+ conn->fd, conn->pidname, state, conn->request_len);
gam_listener_debug(conn->listener);
}
}
Index: server/gam_connection.h
===================================================================
RCS file: /cvs/gnome/gamin/server/gam_connection.h,v
retrieving revision 1.4
diff -u -r1.4 gam_connection.h
--- server/gam_connection.h 12 May 2005 11:38:22 -0000 1.4
+++ server/gam_connection.h 21 Jul 2005 16:32:01 -0000
@@ -36,6 +36,7 @@
int gam_connection_get_fd (GamConnDataPtr conn);
int gam_connection_get_pid (GamConnDataPtr conn);
+gchar * gam_connection_get_pidname (GamConnDataPtr conn);
GamConnState gam_connection_get_state(GamConnDataPtr conn);
int gam_connection_get_data (GamConnDataPtr conn,
char **data,
Index: server/gam_poll.c
===================================================================
RCS file: /cvs/gnome/gamin/server/gam_poll.c,v
retrieving revision 1.60
diff -u -r1.60 gam_poll.c
--- server/gam_poll.c 15 Jun 2005 12:55:56 -0000 1.60
+++ server/gam_poll.c 21 Jul 2005 16:32:02 -0000
@@ -315,8 +315,10 @@
GList *subs;
int is_dir_node = gam_node_is_dir(node);
+#ifdef VERBOSE_POLL
GAM_DEBUG(DEBUG_INFO, "Poll: emit events %d for %s\n",
event, gam_node_get_path(node));
+#endif
subs = gam_node_get_subscriptions(node);
if (subs)
subs = g_list_copy(subs);
@@ -451,7 +453,9 @@
const char *path;
path = gam_node_get_path(node);
+#ifdef VERBOSE_POLL
GAM_DEBUG(DEBUG_INFO, "Poll: poll_file for %s called\n", path);
+#endif
if (node->lasttime == 0) {
GAM_DEBUG(DEBUG_INFO, "Poll: file is new\n");
@@ -470,8 +474,10 @@
else
return GAMIN_EVENT_DELETED;
}
+#ifdef VERBOSE_POLL
GAM_DEBUG(DEBUG_INFO, " at %d delta %d : %d\n", current_time,
current_time - node->lasttime, node->checks);
+#endif
event = 0;
@@ -500,18 +506,22 @@
(node->sbuf.st_ctim.tv_nsec != sbuf.st_ctim.tv_nsec)) {
event = GAMIN_EVENT_CHANGED;
} else {
+#ifdef VERBOSE_POLL
GAM_DEBUG(DEBUG_INFO, "Poll: poll_file %s unchanged\n", path);
GAM_DEBUG(DEBUG_INFO, "%d %d : %d %d\n", node->sbuf.st_mtim.tv_sec,
node->sbuf.st_mtim.tv_nsec, sbuf.st_mtim.tv_sec,
sbuf.st_mtim.tv_nsec);
+#endif
#else
} else if ((node->sbuf.st_mtime != sbuf.st_mtime) ||
(node->sbuf.st_size != sbuf.st_size) ||
(node->sbuf.st_ctime != sbuf.st_ctime)) {
event = GAMIN_EVENT_CHANGED;
+#ifdef VERBOSE_POLL
GAM_DEBUG(DEBUG_INFO, "%d : %d\n", node->sbuf.st_mtime,
sbuf.st_mtime);
#endif
+#endif
}
/*
@@ -542,6 +552,8 @@
if (node->pflags & MON_BUSY) {
if (event == 0)
node->checks++;
+ else
+ node->checks = 0;
} else {
node->checks = 0;
}
@@ -617,9 +629,11 @@
dir = g_dir_open(dpath, 0, NULL);
if (dir == NULL) {
+#ifdef VERBOSE_POLL
GAM_DEBUG(DEBUG_INFO,
"Poll: directory %s is not readable or missing\n",
dpath);
+#endif
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]