summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-05-08 17:23:38 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-05-08 17:23:38 +0900
commit0ba6ddc44a3cb55dcdbd34675afb9025b07ca387 (patch)
tree9eceb748e9cdb263b5742a18f2999baf74e2e91d /src/lib/eina
parent7571020eb8d843d62fdf1580173733d773b024ac (diff)
eina debug - add more comments to debugd connection
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_debug_monitor.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/lib/eina/eina_debug_monitor.c b/src/lib/eina/eina_debug_monitor.c
index fe96326184..324759f2a2 100644
--- a/src/lib/eina/eina_debug_monitor.c
+++ b/src/lib/eina/eina_debug_monitor.c
@@ -296,6 +296,7 @@ _socket_home_get()
296 return dir; 296 return dir;
297} 297}
298 298
299// connect to efl_debugd
299void 300void
300_eina_debug_monitor_service_connect(void) 301_eina_debug_monitor_service_connect(void)
301{ 302{
@@ -303,24 +304,37 @@ _eina_debug_monitor_service_connect(void)
303 int fd, socket_unix_len, curstate = 0; 304 int fd, socket_unix_len, curstate = 0;
304 struct sockaddr_un socket_unix; 305 struct sockaddr_un socket_unix;
305 306
307 // try this socket file - it will likely be:
308 // ~/.ecore/efl_debug/0
309 // or maybe
310 // /var/run/UID/.ecore/efl_debug/0
311 // either way a 4k buffer should be ebough ( if it's not we're on an
312 // insane system)
306 snprintf(buf, sizeof(buf), "%s/%s", _socket_home_get(), DEBUG_SERVER); 313 snprintf(buf, sizeof(buf), "%s/%s", _socket_home_get(), DEBUG_SERVER);
314 // create the socket
307 fd = socket(AF_UNIX, SOCK_STREAM, 0); 315 fd = socket(AF_UNIX, SOCK_STREAM, 0);
308 if (fd < 0) goto err; 316 if (fd < 0) goto err;
317 // set the socket to close when we exec things so they don't inherit it
309 if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) goto err; 318 if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) goto err;
319 // set up some socket options on addr re-use
310 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&curstate, 320 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&curstate,
311 sizeof(curstate)) < 0) 321 sizeof(curstate)) < 0)
312 goto err; 322 goto err;
323 // sa that it's a unix socket and where the path is
313 socket_unix.sun_family = AF_UNIX; 324 socket_unix.sun_family = AF_UNIX;
314 strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path)); 325 strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
315#define LENGTH_OF_SOCKADDR_UN(s) \ 326#define LENGTH_OF_SOCKADDR_UN(s) \
316 (strlen((s)->sun_path) + (size_t)(((struct sockaddr_un *)NULL)->sun_path)) 327 (strlen((s)->sun_path) + (size_t)(((struct sockaddr_un *)NULL)->sun_path))
317 socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix); 328 socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix);
329 // actually conenct to efl_debugd service
318 if (connect(fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0) 330 if (connect(fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0)
319 goto err; 331 goto err;
332 // we succeeded - store fd
320 _eina_debug_monitor_service_fd = fd; 333 _eina_debug_monitor_service_fd = fd;
321 return; 334 return;
322err: 335err:
323 close(fd); 336 // some kind of connection failure here, so close a valid socket and
324 return; 337 // get out of here
338 if (fd >= 0) close(fd);
325} 339}
326#endif 340#endif