Re: minidlna media db. refresh

2015-01-25 Thread LÉVAI Dániel
On h, jan 19, 2015 at 17:16:06 +0100, Antoine Jacoutot wrote:
 On Mon, Jan 19, 2015 at 05:13:09PM +0100, David Coppa wrote:
  On Mon, Jan 19, 2015 at 12:06 AM, LÉVAI Dániel l...@ecentrum.hu wrote:
  
   It might be better to look at the kqueue patch that FreeBSD are using.
  
   Now this seems to work for me on i386, at least. It applied almost
   clean, but I've taken the liberty and removed the whitespace-only
   changes from FreeBSD's diff(s). I'll be honest, it got a bit slower, but
   this could very well be because of my rusty hard drives.
  
   Here is my diff:
  
  I do not use MiniDLNA, but your diff below looks good and, if it
  works, then it's ok with me if Stuart wants to commit it.
 
 There seems to be a missing bdep on the autostuffs.

Thanks! New diff with BUILD_DEPENDS, and some notes/concerns.

While I'm browsing a directory on my tv with pictures in it, during some
(not all) of the thumbnail generations I get these errors in
minidlna.log:

inotify.c:856: warn: kevent polling failure: Interrupted system call

I get like couple of hundreds with more than 500+ pictures in the dir.
I only found this in connection with this error:
http://lists.freebsd.org/pipermail/freebsd-ports/2014-June/093524.html

Which could be suspicious, but it really can't seem to hurt anything
(except the growing log file).

Anyway, one of the most annoying things while I was testing was the
(duplicate) re-appearance of the network server in the tv's network
browser menu, after every minidlnad restart. Turns out, it generates a
random uuid on every startup if one is not defined in the configuration
file. So I inserted an example uuid= line into the minidlna.conf config
file with a short comment.

Given that I also experienced a general slowness when using kevents,
this update seems a bit shaky to me; nevertheless, it seems to be
working.

Maybe by default, we could disable inotify in the config, and just
write a notice after package install that the user has the option to
turn this on, with some fair warnings?



Index: Makefile
===
RCS file: /cvs/ports/multimedia/minidlna/Makefile,v
retrieving revision 1.10
diff -p -u -r1.10 Makefile
--- Makefile3 Sep 2014 21:15:43 -   1.10
+++ Makefile25 Jan 2015 10:00:53 -
@@ -3,6 +3,7 @@
 COMMENT=   lightweight DLNA/UPnP-AV media server
 
 V= 1.1.4
+REVISION=  0
 DISTNAME=  minidlna-$V
 PKGNAME=   minidlna-$V
 
@@ -28,15 +29,25 @@ CONFIGURE_ENV=  CPPFLAGS=-I${LOCALBASE}/
LDFLAGS=-L${LOCALBASE}/lib
 
 MODULES=   devel/gettext
+
+BUILD_DEPENDS= devel/autoconf/2.69 \
+   devel/automake/1.14
+
 LIB_DEPENDS=   audio/flac \
audio/libid3tag \
graphics/ffmpeg \
graphics/jpeg \
graphics/libexif
 
+AUTOCONF_VERSION= 2.69
+AUTOMAKE_VERSION= 1.14
+
 NO_TEST=   Yes
 E= ${PREFIX}/share/examples/minidlna
 
+post-patch:
+   @cd ${WRKSRC}  env AUTOCONF_VERSION=${AUTOCONF_VERSION} \
+   AUTOMAKE_VERSION=${AUTOMAKE_VERSION} ./autogen.sh
 post-install:
${INSTALL_DATA_DIR} $E
${INSTALL_DATA} ${WRKSRC}/minidlna.conf $E
Index: patches/patch-configure_ac
===
RCS file: patches/patch-configure_ac
diff -N patches/patch-configure_ac
--- /dev/null   1 Jan 1970 00:00:00 -
+++ patches/patch-configure_ac  25 Jan 2015 10:00:53 -
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- configure.ac.orig  Tue Aug 26 23:09:22 2014
 configure.ac   Sun Jan 18 22:45:07 2015
+@@ -481,7 +481,7 @@ AC_CHECK_LIB(vorbisfile, vorbis_comment_query,
+ 

+ ### Header checks
+ 
+-AC_CHECK_HEADERS([arpa/inet.h asm/unistd.h endian.h machine/endian.h fcntl.h 
libintl.h locale.h netdb.h netinet/in.h stddef.h stdlib.h string.h sys/file.h 
sys/inotify.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h])
++AC_CHECK_HEADERS([arpa/inet.h asm/unistd.h endian.h machine/endian.h fcntl.h 
libintl.h locale.h netdb.h netinet/in.h stddef.h stdlib.h string.h sys/file.h 
sys/inotify.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h 
sys/event.h])
+ 
+ AC_CHECK_FUNCS(inotify_init, AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has 
inotify support]), [
+ AC_MSG_CHECKING([for __NR_inotify_init syscall])
Index: patches/patch-inotify_c
===
RCS file: patches/patch-inotify_c
diff -N patches/patch-inotify_c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ patches/patch-inotify_c 25 Jan 2015 10:00:53 -
@@ -0,0 +1,469 @@
+$OpenBSD$
+--- inotify.c.orig Tue Aug 26 23:09:22 2014
 inotify.c  Sun Jan 18 23:53:30 2015
+@@ -17,7 +17,7 @@
+  */
+ #include config.h
+ 
+-#ifdef HAVE_INOTIFY
++#if defined(HAVE_INOTIFY) || defined(HAVE_SYS_EVENT_H)
+ #include 

Re: minidlna media db. refresh

2015-01-25 Thread Stuart Henderson
On 2015/01/25 11:03, LÉVAI Dániel wrote:
 Given that I also experienced a general slowness when using kevents,
 this update seems a bit shaky to me; nevertheless, it seems to be
 working.
 
 Maybe by default, we could disable inotify in the config, and just
 write a notice after package install that the user has the option to
 turn this on, with some fair warnings?

I'm a bit unsure about whether to include this in the port at this time,
so for now I've just taken a slightly modified version of the config
diff to mention uuid, and will look at the kevent parts in more detail
when I have more time..

 +BUILD_DEPENDS=   devel/autoconf/2.69 \
 + devel/automake/1.14

btw these ones should use the MODGNU_AUTO*_DEPENDS variables which are
set automatically from AUTO*_VERSION, rather than hardcoding the port
specs here.




Re: minidlna media db. refresh

2015-01-19 Thread David Coppa
On Mon, Jan 19, 2015 at 12:06 AM, LÉVAI Dániel l...@ecentrum.hu wrote:

 It might be better to look at the kqueue patch that FreeBSD are using.

 Now this seems to work for me on i386, at least. It applied almost
 clean, but I've taken the liberty and removed the whitespace-only
 changes from FreeBSD's diff(s). I'll be honest, it got a bit slower, but
 this could very well be because of my rusty hard drives.

 Here is my diff:

I do not use MiniDLNA, but your diff below looks good and, if it
works, then it's ok with me if Stuart wants to commit it.

ciao,
David


 Index: Makefile
 ===
 RCS file: /cvs/ports/multimedia/minidlna/Makefile,v
 retrieving revision 1.10
 diff -p -u -r1.10 Makefile
 --- Makefile3 Sep 2014 21:15:43 -   1.10
 +++ Makefile18 Jan 2015 22:45:10 -
 @@ -3,6 +3,7 @@
  COMMENT=   lightweight DLNA/UPnP-AV media server

  V= 1.1.4
 +REVISION=  0
  DISTNAME=  minidlna-$V
  PKGNAME=   minidlna-$V

 @@ -34,9 +35,15 @@ LIB_DEPENDS= audio/flac \
 graphics/jpeg \
 graphics/libexif

 +AUTOCONF_VERSION= 2.69
 +AUTOMAKE_VERSION= 1.14
 +
  NO_TEST=   Yes
  E= ${PREFIX}/share/examples/minidlna

 +post-patch:
 +   @cd ${WRKSRC}  env AUTOCONF_VERSION=${AUTOCONF_VERSION} \
 +   AUTOMAKE_VERSION=${AUTOMAKE_VERSION} ./autogen.sh
  post-install:
 ${INSTALL_DATA_DIR} $E
 ${INSTALL_DATA} ${WRKSRC}/minidlna.conf $E
 Index: patches/patch-configure_ac
 ===
 RCS file: patches/patch-configure_ac
 diff -N patches/patch-configure_ac
 --- /dev/null   1 Jan 1970 00:00:00 -
 +++ patches/patch-configure_ac  18 Jan 2015 22:45:10 -
 @@ -0,0 +1,12 @@
 +$OpenBSD$
 +--- configure.ac.orig  Tue Aug 26 23:09:22 2014
  configure.ac   Sun Jan 18 22:45:07 2015
 +@@ -481,7 +481,7 @@ AC_CHECK_LIB(vorbisfile, vorbis_comment_query,
 + 
 
 + ### Header checks
 +
 +-AC_CHECK_HEADERS([arpa/inet.h asm/unistd.h endian.h machine/endian.h 
 fcntl.h libintl.h locale.h netdb.h netinet/in.h stddef.h stdlib.h string.h 
 sys/file.h sys/inotify.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h 
 unistd.h])
 ++AC_CHECK_HEADERS([arpa/inet.h asm/unistd.h endian.h machine/endian.h 
 fcntl.h libintl.h locale.h netdb.h netinet/in.h stddef.h stdlib.h string.h 
 sys/file.h sys/inotify.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h 
 unistd.h sys/event.h])
 +
 + AC_CHECK_FUNCS(inotify_init, AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has 
 inotify support]), [
 + AC_MSG_CHECKING([for __NR_inotify_init syscall])
 Index: patches/patch-inotify_c
 ===
 RCS file: patches/patch-inotify_c
 diff -N patches/patch-inotify_c
 --- /dev/null   1 Jan 1970 00:00:00 -
 +++ patches/patch-inotify_c 18 Jan 2015 22:45:10 -
 @@ -0,0 +1,569 @@
 +$OpenBSD$
 +--- inotify.c.orig Sun Jan 18 22:45:24 2015
  inotify.c  Sun Jan 18 22:45:27 2015
 +@@ -15,9 +15,9 @@
 +  * You should have received a copy of the GNU General Public License
 +  * along with MiniDLNA. If not, see http://www.gnu.org/licenses/.
 +  */
 + #include config.h
 +
 +-#ifdef HAVE_INOTIFY
 ++#if defined(HAVE_INOTIFY) || defined(HAVE_SYS_EVENT_H)
 + #include stdio.h
 + #include string.h
 + #include stdlib.h
 +@@ -31,11 +31,16 @@
 + #include sys/time.h
 + #include sys/resource.h
 + #include poll.h
 ++#ifdef HAVE_INOTIFY
 + #ifdef HAVE_SYS_INOTIFY_H
 + #include sys/inotify.h
 +-#else
 ++#else /*HAVE_SYS_INOTIFY_H*/
 + #include linux/inotify.h
 + #include linux/inotify-syscalls.h
 ++#endif /*HAVE_SYS_INOTIFY_H*/
 ++#else
 ++#include sys/event.h
 ++#include fcntl.h
 + #endif
 + #include libav.h
 +
 +@@ -49,11 +54,13 @@
 + #include playlist.h
 + #include log.h
 +
 ++#ifdef HAVE_INOTIFY
 + #define EVENT_SIZE  ( sizeof (struct inotify_event) )
 + #define BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) )
 + #define DESIRED_WATCH_LIMIT 65536
 +
 + #define PATH_BUF_SIZE PATH_MAX
 ++#endif
 +
 + struct watch
 + {
 +@@ -86,13 +93,35 @@ add_watch(int fd, const char * path)
 +   struct watch *nw;
 +   int wd;
 +
 ++#ifdef HAVE_INOTIFY
 +   wd = inotify_add_watch(fd, path, 
 IN_CREATE|IN_CLOSE_WRITE|IN_DELETE|IN_MOVE);
 +   if( wd  0 )
 +   {
 +   DPRINTF(E_ERROR, L_INOTIFY, inotify_add_watch(%s) [%s]\n, 
 path, strerror(errno));
 +   return -1;
 +   }
 ++#else /*HAVE_INOTIFY*/
 ++  wd = open(path, O_RDONLY);
 ++  if (wd == -1)
 ++  {
 ++  DPRINTF(E_ERROR, L_INOTIFY, 
 inotify_add_watch[kqueue,open](%s) [%s]\n, path, strerror(errno));
 ++  return -1;
 ++  }
 +
 ++  struct kevent ke;
 ++  EV_SET(ke, wd,
 ++  EVFILT_VNODE,
 ++  EV_ADD | EV_ENABLE | EV_CLEAR,
 ++  

Re: minidlna media db. refresh

2015-01-19 Thread Antoine Jacoutot
On Mon, Jan 19, 2015 at 05:13:09PM +0100, David Coppa wrote:
 On Mon, Jan 19, 2015 at 12:06 AM, LÉVAI Dániel l...@ecentrum.hu wrote:
 
  It might be better to look at the kqueue patch that FreeBSD are using.
 
  Now this seems to work for me on i386, at least. It applied almost
  clean, but I've taken the liberty and removed the whitespace-only
  changes from FreeBSD's diff(s). I'll be honest, it got a bit slower, but
  this could very well be because of my rusty hard drives.
 
  Here is my diff:
 
 I do not use MiniDLNA, but your diff below looks good and, if it
 works, then it's ok with me if Stuart wants to commit it.

There seems to be a missing bdep on the autostuffs.

 
 ciao,
 David
 
 
  Index: Makefile
  ===
  RCS file: /cvs/ports/multimedia/minidlna/Makefile,v
  retrieving revision 1.10
  diff -p -u -r1.10 Makefile
  --- Makefile3 Sep 2014 21:15:43 -   1.10
  +++ Makefile18 Jan 2015 22:45:10 -
  @@ -3,6 +3,7 @@
   COMMENT=   lightweight DLNA/UPnP-AV media server
 
   V= 1.1.4
  +REVISION=  0
   DISTNAME=  minidlna-$V
   PKGNAME=   minidlna-$V
 
  @@ -34,9 +35,15 @@ LIB_DEPENDS= audio/flac \
  graphics/jpeg \
  graphics/libexif
 
  +AUTOCONF_VERSION= 2.69
  +AUTOMAKE_VERSION= 1.14
  +
   NO_TEST=   Yes
   E= ${PREFIX}/share/examples/minidlna
 
  +post-patch:
  +   @cd ${WRKSRC}  env AUTOCONF_VERSION=${AUTOCONF_VERSION} \
  +   AUTOMAKE_VERSION=${AUTOMAKE_VERSION} ./autogen.sh
   post-install:
  ${INSTALL_DATA_DIR} $E
  ${INSTALL_DATA} ${WRKSRC}/minidlna.conf $E
  Index: patches/patch-configure_ac
  ===
  RCS file: patches/patch-configure_ac
  diff -N patches/patch-configure_ac
  --- /dev/null   1 Jan 1970 00:00:00 -
  +++ patches/patch-configure_ac  18 Jan 2015 22:45:10 -
  @@ -0,0 +1,12 @@
  +$OpenBSD$
  +--- configure.ac.orig  Tue Aug 26 23:09:22 2014
   configure.ac   Sun Jan 18 22:45:07 2015
  +@@ -481,7 +481,7 @@ AC_CHECK_LIB(vorbisfile, vorbis_comment_query,
  + 
  
  + ### Header checks
  +
  +-AC_CHECK_HEADERS([arpa/inet.h asm/unistd.h endian.h machine/endian.h 
  fcntl.h libintl.h locale.h netdb.h netinet/in.h stddef.h stdlib.h string.h 
  sys/file.h sys/inotify.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h 
  unistd.h])
  ++AC_CHECK_HEADERS([arpa/inet.h asm/unistd.h endian.h machine/endian.h 
  fcntl.h libintl.h locale.h netdb.h netinet/in.h stddef.h stdlib.h string.h 
  sys/file.h sys/inotify.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h 
  unistd.h sys/event.h])
  +
  + AC_CHECK_FUNCS(inotify_init, AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has 
  inotify support]), [
  + AC_MSG_CHECKING([for __NR_inotify_init syscall])
  Index: patches/patch-inotify_c
  ===
  RCS file: patches/patch-inotify_c
  diff -N patches/patch-inotify_c
  --- /dev/null   1 Jan 1970 00:00:00 -
  +++ patches/patch-inotify_c 18 Jan 2015 22:45:10 -
  @@ -0,0 +1,569 @@
  +$OpenBSD$
  +--- inotify.c.orig Sun Jan 18 22:45:24 2015
   inotify.c  Sun Jan 18 22:45:27 2015
  +@@ -15,9 +15,9 @@
  +  * You should have received a copy of the GNU General Public License
  +  * along with MiniDLNA. If not, see http://www.gnu.org/licenses/.
  +  */
  + #include config.h
  +
  +-#ifdef HAVE_INOTIFY
  ++#if defined(HAVE_INOTIFY) || defined(HAVE_SYS_EVENT_H)
  + #include stdio.h
  + #include string.h
  + #include stdlib.h
  +@@ -31,11 +31,16 @@
  + #include sys/time.h
  + #include sys/resource.h
  + #include poll.h
  ++#ifdef HAVE_INOTIFY
  + #ifdef HAVE_SYS_INOTIFY_H
  + #include sys/inotify.h
  +-#else
  ++#else /*HAVE_SYS_INOTIFY_H*/
  + #include linux/inotify.h
  + #include linux/inotify-syscalls.h
  ++#endif /*HAVE_SYS_INOTIFY_H*/
  ++#else
  ++#include sys/event.h
  ++#include fcntl.h
  + #endif
  + #include libav.h
  +
  +@@ -49,11 +54,13 @@
  + #include playlist.h
  + #include log.h
  +
  ++#ifdef HAVE_INOTIFY
  + #define EVENT_SIZE  ( sizeof (struct inotify_event) )
  + #define BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) )
  + #define DESIRED_WATCH_LIMIT 65536
  +
  + #define PATH_BUF_SIZE PATH_MAX
  ++#endif
  +
  + struct watch
  + {
  +@@ -86,13 +93,35 @@ add_watch(int fd, const char * path)
  +   struct watch *nw;
  +   int wd;
  +
  ++#ifdef HAVE_INOTIFY
  +   wd = inotify_add_watch(fd, path, 
  IN_CREATE|IN_CLOSE_WRITE|IN_DELETE|IN_MOVE);
  +   if( wd  0 )
  +   {
  +   DPRINTF(E_ERROR, L_INOTIFY, inotify_add_watch(%s) [%s]\n, 
  path, strerror(errno));
  +   return -1;
  +   }
  ++#else /*HAVE_INOTIFY*/
  ++  wd = open(path, O_RDONLY);
  ++  if (wd == -1)
  ++  {
  ++  

Re: minidlna media db. refresh

2015-01-19 Thread Martijn van Duren

On 01/19/15 17:13, David Coppa wrote:

On Mon, Jan 19, 2015 at 12:06 AM, LÉVAI Dániel l...@ecentrum.hu wrote:


It might be better to look at the kqueue patch that FreeBSD are using.


Now this seems to work for me on i386, at least. It applied almost
clean, but I've taken the liberty and removed the whitespace-only
changes from FreeBSD's diff(s). I'll be honest, it got a bit slower, but
this could very well be because of my rusty hard drives.

Here is my diff:


I do not use MiniDLNA, but your diff below looks good and, if it
works, then it's ok with me if Stuart wants to commit it.


How will this patch affect libraries with more then 512 directories, 
since kqueue is restricted by the limit of open file descriptors?

martijn@donar:/home/multimedia/Video's$ ulimit -n
512
martijn@donar:/home/multimedia/Video's$ find . -type d | wc -l
2345
martijn@donar:/home/multimedia/Video's$ find . -type f | wc -l
   57640



ciao,
David



Index: Makefile
===
RCS file: /cvs/ports/multimedia/minidlna/Makefile,v
retrieving revision 1.10
diff -p -u -r1.10 Makefile
--- Makefile3 Sep 2014 21:15:43 -   1.10
+++ Makefile18 Jan 2015 22:45:10 -
@@ -3,6 +3,7 @@
  COMMENT=   lightweight DLNA/UPnP-AV media server

  V= 1.1.4
+REVISION=  0
  DISTNAME=  minidlna-$V
  PKGNAME=   minidlna-$V

@@ -34,9 +35,15 @@ LIB_DEPENDS= audio/flac \
 graphics/jpeg \
 graphics/libexif

+AUTOCONF_VERSION= 2.69
+AUTOMAKE_VERSION= 1.14
+
  NO_TEST=   Yes
  E= ${PREFIX}/share/examples/minidlna

+post-patch:
+   @cd ${WRKSRC}  env AUTOCONF_VERSION=${AUTOCONF_VERSION} \
+   AUTOMAKE_VERSION=${AUTOMAKE_VERSION} ./autogen.sh
  post-install:
 ${INSTALL_DATA_DIR} $E
 ${INSTALL_DATA} ${WRKSRC}/minidlna.conf $E
Index: patches/patch-configure_ac
===
RCS file: patches/patch-configure_ac
diff -N patches/patch-configure_ac
--- /dev/null   1 Jan 1970 00:00:00 -
+++ patches/patch-configure_ac  18 Jan 2015 22:45:10 -
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- configure.ac.orig  Tue Aug 26 23:09:22 2014
 configure.ac   Sun Jan 18 22:45:07 2015
+@@ -481,7 +481,7 @@ AC_CHECK_LIB(vorbisfile, vorbis_comment_query,
+ 

+ ### Header checks
+
+-AC_CHECK_HEADERS([arpa/inet.h asm/unistd.h endian.h machine/endian.h fcntl.h 
libintl.h locale.h netdb.h netinet/in.h stddef.h stdlib.h string.h sys/file.h 
sys/inotify.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h])
++AC_CHECK_HEADERS([arpa/inet.h asm/unistd.h endian.h machine/endian.h fcntl.h 
libintl.h locale.h netdb.h netinet/in.h stddef.h stdlib.h string.h sys/file.h 
sys/inotify.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h 
sys/event.h])
+
+ AC_CHECK_FUNCS(inotify_init, AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has 
inotify support]), [
+ AC_MSG_CHECKING([for __NR_inotify_init syscall])
Index: patches/patch-inotify_c
===
RCS file: patches/patch-inotify_c
diff -N patches/patch-inotify_c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ patches/patch-inotify_c 18 Jan 2015 22:45:10 -
@@ -0,0 +1,569 @@
+$OpenBSD$
+--- inotify.c.orig Sun Jan 18 22:45:24 2015
 inotify.c  Sun Jan 18 22:45:27 2015
+@@ -15,9 +15,9 @@
+  * You should have received a copy of the GNU General Public License
+  * along with MiniDLNA. If not, see http://www.gnu.org/licenses/.
+  */
+ #include config.h
+
+-#ifdef HAVE_INOTIFY
++#if defined(HAVE_INOTIFY) || defined(HAVE_SYS_EVENT_H)
+ #include stdio.h
+ #include string.h
+ #include stdlib.h
+@@ -31,11 +31,16 @@
+ #include sys/time.h
+ #include sys/resource.h
+ #include poll.h
++#ifdef HAVE_INOTIFY
+ #ifdef HAVE_SYS_INOTIFY_H
+ #include sys/inotify.h
+-#else
++#else /*HAVE_SYS_INOTIFY_H*/
+ #include linux/inotify.h
+ #include linux/inotify-syscalls.h
++#endif /*HAVE_SYS_INOTIFY_H*/
++#else
++#include sys/event.h
++#include fcntl.h
+ #endif
+ #include libav.h
+
+@@ -49,11 +54,13 @@
+ #include playlist.h
+ #include log.h
+
++#ifdef HAVE_INOTIFY
+ #define EVENT_SIZE  ( sizeof (struct inotify_event) )
+ #define BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) )
+ #define DESIRED_WATCH_LIMIT 65536
+
+ #define PATH_BUF_SIZE PATH_MAX
++#endif
+
+ struct watch
+ {
+@@ -86,13 +93,35 @@ add_watch(int fd, const char * path)
+   struct watch *nw;
+   int wd;
+
++#ifdef HAVE_INOTIFY
+   wd = inotify_add_watch(fd, path, 
IN_CREATE|IN_CLOSE_WRITE|IN_DELETE|IN_MOVE);
+   if( wd  0 )
+   {
+   DPRINTF(E_ERROR, L_INOTIFY, inotify_add_watch(%s) [%s]\n, 
path, strerror(errno));
+   return -1;
+   }
++#else /*HAVE_INOTIFY*/
++  wd = open(path, O_RDONLY);
++  if (wd == -1)
++  {
++  

Re: minidlna media db. refresh

2015-01-19 Thread LÉVAI Dániel
On h, jan 19, 2015 at 18:53:48 +0100, Martijn van Duren wrote:
 On 01/19/15 17:13, David Coppa wrote:
 On Mon, Jan 19, 2015 at 12:06 AM, LÉVAI Dániel l...@ecentrum.hu wrote:
 
 It might be better to look at the kqueue patch that FreeBSD are using.
 
 Now this seems to work for me on i386, at least. It applied almost
 clean, but I've taken the liberty and removed the whitespace-only
 changes from FreeBSD's diff(s). I'll be honest, it got a bit slower, but
 this could very well be because of my rusty hard drives.
 
 Here is my diff:
 
 I do not use MiniDLNA, but your diff below looks good and, if it
 works, then it's ok with me if Stuart wants to commit it.
 
 How will this patch affect libraries with more then 512 directories, since
 kqueue is restricted by the limit of open file descriptors?
 martijn@donar:/home/multimedia/Video's$ ulimit -n
 512
 martijn@donar:/home/multimedia/Video's$ find . -type d | wc -l
 2345
 martijn@donar:/home/multimedia/Video's$ find . -type f | wc -l
57640
 
[...]

I think that's why we need testing :)


Daniel

 
 Comments, tests?
 
 
 Daniel
 
 --
 LÉVAI Dániel
 PGP key ID = 0x83B63A8F
 Key fingerprint = DBEC C66B A47A DFA2 792D  650C C69B BE4C 83B6 3A8F

-- 
LÉVAI Dániel
PGP key ID = 0x83B63A8F
Key fingerprint = DBEC C66B A47A DFA2 792D  650C C69B BE4C 83B6 3A8F



Re: minidlna media db. refresh

2015-01-18 Thread Rafael Sadowski
On Sun Jan 18, 2015 at 05:42:05PM +0100, LÉVAI Dániel wrote:
 Hi!
 
 Has anyone ever had a problem with minidlna not refreshing its media
 library automatically (on -current)?
 Does this only work on Linux w/ inotify?
 
 
 Daniel
 
 -- 
 LÉVAI Dániel
 PGP key ID = 0x83B63A8F
 Key fingerprint = DBEC C66B A47A DFA2 792D  650C C69B BE4C 83B6 3A8F

Workaround:

sudo rm -f /var/db/minidlna/files.db   sudo rcctl restart minidlna



Re: minidlna media db. refresh

2015-01-18 Thread Stuart Henderson
On 2015/01/18 19:10, David Coppa wrote:
 On Sun, Jan 18, 2015 at 6:38 PM, Stuart Henderson st...@openbsd.org wrote:
  On 2015/01/18 17:42, LÉVAI Dániel wrote:
  Hi!
 
  Has anyone ever had a problem with minidlna not refreshing its media
  library automatically (on -current)?
 
  That's expected.
 
  Does this only work on Linux w/ inotify?
 
  yep.
 
 Daniel, maybe you could investigate if devel/libinotify is good enough for it.

It might be better to look at the kqueue patch that FreeBSD are using.




minidlna media db. refresh

2015-01-18 Thread LÉVAI Dániel
Hi!

Has anyone ever had a problem with minidlna not refreshing its media
library automatically (on -current)?
Does this only work on Linux w/ inotify?


Daniel

-- 
LÉVAI Dániel
PGP key ID = 0x83B63A8F
Key fingerprint = DBEC C66B A47A DFA2 792D  650C C69B BE4C 83B6 3A8F



Re: minidlna media db. refresh

2015-01-18 Thread David Coppa
On Sun, Jan 18, 2015 at 6:38 PM, Stuart Henderson st...@openbsd.org wrote:
 On 2015/01/18 17:42, LÉVAI Dániel wrote:
 Hi!

 Has anyone ever had a problem with minidlna not refreshing its media
 library automatically (on -current)?

 That's expected.

 Does this only work on Linux w/ inotify?

 yep.

Daniel, maybe you could investigate if devel/libinotify is good enough for it.

Ciao,
David
-- 
If you try a few times and give up, you'll never get there. But if
you keep at it... There's a lot of problems in the world which can
really be solved by applying two or three times the persistence that
other people will.
-- Stewart Nelson



Re: minidlna media db. refresh

2015-01-18 Thread Stuart Henderson
On 2015/01/18 17:42, LÉVAI Dániel wrote:
 Hi!
 
 Has anyone ever had a problem with minidlna not refreshing its media
 library automatically (on -current)?

That's expected.

 Does this only work on Linux w/ inotify?

yep.

I have set this in pkg.conf to rescan at startup:

minidlna_flags=-R

it's appropriate for some uses but not others.



Re: minidlna media db. refresh

2015-01-18 Thread LÉVAI Dániel
On v, jan 18, 2015 at 19:57:44 +, Stuart Henderson wrote:
 On 2015/01/18 19:10, David Coppa wrote:
  On Sun, Jan 18, 2015 at 6:38 PM, Stuart Henderson st...@openbsd.org wrote:
   On 2015/01/18 17:42, LÉVAI Dániel wrote:
   Hi!
  
   Has anyone ever had a problem with minidlna not refreshing its media
   library automatically (on -current)?
  
   That's expected.
  
   Does this only work on Linux w/ inotify?
  
   yep.
  
  Daniel, maybe you could investigate if devel/libinotify is good enough for 
  it.

Yeah, I got it compiled, but the first thing was a segfault, and I
didn't even bother to dig deeper after I read sthen@'s mail about a
patch to support kqueue/kevent in FreeBSD's ports tree :-) Also, it
seems with libinotify's lib installed in an unusual place (lib/inotify),
one would had to start minidlnad with LD_LIBRARY_FLAGS set -- but of
course, I may be incorrect.

 It might be better to look at the kqueue patch that FreeBSD are using.

Now this seems to work for me on i386, at least. It applied almost
clean, but I've taken the liberty and removed the whitespace-only
changes from FreeBSD's diff(s). I'll be honest, it got a bit slower, but
this could very well be because of my rusty hard drives.

Here is my diff:


Index: Makefile
===
RCS file: /cvs/ports/multimedia/minidlna/Makefile,v
retrieving revision 1.10
diff -p -u -r1.10 Makefile
--- Makefile3 Sep 2014 21:15:43 -   1.10
+++ Makefile18 Jan 2015 22:45:10 -
@@ -3,6 +3,7 @@
 COMMENT=   lightweight DLNA/UPnP-AV media server
 
 V= 1.1.4
+REVISION=  0
 DISTNAME=  minidlna-$V
 PKGNAME=   minidlna-$V
 
@@ -34,9 +35,15 @@ LIB_DEPENDS= audio/flac \
graphics/jpeg \
graphics/libexif
 
+AUTOCONF_VERSION= 2.69
+AUTOMAKE_VERSION= 1.14
+
 NO_TEST=   Yes
 E= ${PREFIX}/share/examples/minidlna
 
+post-patch:
+   @cd ${WRKSRC}  env AUTOCONF_VERSION=${AUTOCONF_VERSION} \
+   AUTOMAKE_VERSION=${AUTOMAKE_VERSION} ./autogen.sh
 post-install:
${INSTALL_DATA_DIR} $E
${INSTALL_DATA} ${WRKSRC}/minidlna.conf $E
Index: patches/patch-configure_ac
===
RCS file: patches/patch-configure_ac
diff -N patches/patch-configure_ac
--- /dev/null   1 Jan 1970 00:00:00 -
+++ patches/patch-configure_ac  18 Jan 2015 22:45:10 -
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- configure.ac.orig  Tue Aug 26 23:09:22 2014
 configure.ac   Sun Jan 18 22:45:07 2015
+@@ -481,7 +481,7 @@ AC_CHECK_LIB(vorbisfile, vorbis_comment_query,
+ 

+ ### Header checks
+ 
+-AC_CHECK_HEADERS([arpa/inet.h asm/unistd.h endian.h machine/endian.h fcntl.h 
libintl.h locale.h netdb.h netinet/in.h stddef.h stdlib.h string.h sys/file.h 
sys/inotify.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h])
++AC_CHECK_HEADERS([arpa/inet.h asm/unistd.h endian.h machine/endian.h fcntl.h 
libintl.h locale.h netdb.h netinet/in.h stddef.h stdlib.h string.h sys/file.h 
sys/inotify.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h 
sys/event.h])
+ 
+ AC_CHECK_FUNCS(inotify_init, AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has 
inotify support]), [
+ AC_MSG_CHECKING([for __NR_inotify_init syscall])
Index: patches/patch-inotify_c
===
RCS file: patches/patch-inotify_c
diff -N patches/patch-inotify_c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ patches/patch-inotify_c 18 Jan 2015 22:45:10 -
@@ -0,0 +1,569 @@
+$OpenBSD$
+--- inotify.c.orig Sun Jan 18 22:45:24 2015
 inotify.c  Sun Jan 18 22:45:27 2015
+@@ -15,9 +15,9 @@
+  * You should have received a copy of the GNU General Public License
+  * along with MiniDLNA. If not, see http://www.gnu.org/licenses/.
+  */
+ #include config.h
+ 
+-#ifdef HAVE_INOTIFY
++#if defined(HAVE_INOTIFY) || defined(HAVE_SYS_EVENT_H)
+ #include stdio.h
+ #include string.h
+ #include stdlib.h
+@@ -31,11 +31,16 @@
+ #include sys/time.h
+ #include sys/resource.h
+ #include poll.h
++#ifdef HAVE_INOTIFY
+ #ifdef HAVE_SYS_INOTIFY_H
+ #include sys/inotify.h
+-#else
++#else /*HAVE_SYS_INOTIFY_H*/
+ #include linux/inotify.h
+ #include linux/inotify-syscalls.h
++#endif /*HAVE_SYS_INOTIFY_H*/
++#else
++#include sys/event.h
++#include fcntl.h
+ #endif
+ #include libav.h
+ 
+@@ -49,11 +54,13 @@
+ #include playlist.h
+ #include log.h
+ 
++#ifdef HAVE_INOTIFY
+ #define EVENT_SIZE  ( sizeof (struct inotify_event) )
+ #define BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) )
+ #define DESIRED_WATCH_LIMIT 65536
+ 
+ #define PATH_BUF_SIZE PATH_MAX
++#endif
+ 
+ struct watch
+ {
+@@ -86,13 +93,35 @@ add_watch(int fd, const char * path)
+   struct watch *nw;
+   int wd;
+ 
++#ifdef HAVE_INOTIFY
+   wd = inotify_add_watch(fd, path,