Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Mar 2013 17:19:06 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r314749 - in head/x11-wm/i3: . files
Message-ID:  <201303201719.r2KHJ6l4013640@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Wed Mar 20 17:19:06 2013
New Revision: 314749
URL: http://svnweb.freebsd.org/changeset/ports/314749

Log:
  Add a patch to make the optional shmlog mechanism works on FreeBSD.
  This allows users to use i3-dump-log to gets logs out of i3 is it was run with the shmlog-size parameter set to something greater than 0

Added:
  head/x11-wm/i3/files/
  head/x11-wm/i3/files/patch-src__log.c   (contents, props changed)
Modified:
  head/x11-wm/i3/Makefile

Modified: head/x11-wm/i3/Makefile
==============================================================================
--- head/x11-wm/i3/Makefile	Wed Mar 20 17:13:42 2013	(r314748)
+++ head/x11-wm/i3/Makefile	Wed Mar 20 17:19:06 2013	(r314749)
@@ -3,6 +3,7 @@
 
 PORTNAME=	i3
 DISTVERSION=	4.5.1
+PORTREVISION=	1
 CATEGORIES=	x11-wm
 MASTER_SITES=	http://i3wm.org/downloads/ \
 		${MASTER_SITE_LOCAL}

Added: head/x11-wm/i3/files/patch-src__log.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/x11-wm/i3/files/patch-src__log.c	Wed Mar 20 17:19:06 2013	(r314749)
@@ -0,0 +1,68 @@
+--- ./src/log.c.orig	2013-03-20 15:28:14.746383400 +0100
++++ ./src/log.c	2013-03-20 18:27:56.885378021 +0100
+@@ -81,11 +81,11 @@
+ void init_logging(void) {
+     if (!errorfilename) {
+         if (!(errorfilename = get_process_filename("errorlog")))
+-            ELOG("Could not initialize errorlog\n");
++            fprintf(stderr, "Could not initialize errorlog\n");
+         else {
+             errorfile = fopen(errorfilename, "w");
+             if (fcntl(fileno(errorfile), F_SETFD, FD_CLOEXEC)) {
+-                ELOG("Could not set close-on-exec flag\n");
++                fprintf(stderr, "Could not set close-on-exec flag\n");
+             }
+         }
+     }
+@@ -107,25 +107,28 @@
+                                         sysconf(_SC_PAGESIZE);
+ #endif
+         logbuffer_size = min(physical_mem_bytes * 0.01, shmlog_size);
+-        sasprintf(&shmlogname, "/i3-log-%d", getpid());
++#if defined(__FreeBSD__)
++	asprintf(&shmlogname, "/tmp/i3-log-%d", getpid());
++#else
++        asprintf(&shmlogname, "/i3-log-%d", getpid());
++#endif
+         logbuffer_shm = shm_open(shmlogname, O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
+         if (logbuffer_shm == -1) {
+-            ELOG("Could not shm_open SHM segment for the i3 log: %s\n", strerror(errno));
++            fprintf(stderr, "Could not shm_open SHM segment for the i3 log: %s\n", strerror(errno));
+             return;
+         }
+-
+         if (ftruncate(logbuffer_shm, logbuffer_size) == -1) {
+             close(logbuffer_shm);
+-            shm_unlink("/i3-log-");
+-            ELOG("Could not ftruncate SHM segment for the i3 log: %s\n", strerror(errno));
++            shm_unlink(shmlogname);
++            fprintf(stderr, "Could not ftruncate SHM segment for the i3 log: %s\n", strerror(errno));
+             return;
+         }
+ 
+         logbuffer = mmap(NULL, logbuffer_size, PROT_READ | PROT_WRITE, MAP_SHARED, logbuffer_shm, 0);
+         if (logbuffer == MAP_FAILED) {
+             close(logbuffer_shm);
+-            shm_unlink("/i3-log-");
+-            ELOG("Could not mmap SHM segment for the i3 log: %s\n", strerror(errno));
++            shm_unlink(shmlogname);
++            fprintf(stderr, "Could not mmap SHM segment for the i3 log: %s\n", strerror(errno));
+             logbuffer = NULL;
+             return;
+         }
+@@ -138,13 +141,14 @@
+         pthread_condattr_t cond_attr;
+         pthread_condattr_init(&cond_attr);
+         if (pthread_condattr_setpshared(&cond_attr, PTHREAD_PROCESS_SHARED) != 0)
+-            ELOG("pthread_condattr_setpshared() failed, i3-dump-log -f will not work!\n");
++            fprintf(stderr, "pthread_condattr_setpshared() failed, i3-dump-log -f will not work!\n");
+         pthread_cond_init(&(header->condvar), &cond_attr);
+ 
+         logwalk = logbuffer + sizeof(i3_shmlog_header);
+         loglastwrap = logbuffer + logbuffer_size;
+         store_log_markers();
+     }
++
+     atexit(purge_zerobyte_logfile);
+ }
+ 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303201719.r2KHJ6l4013640>