Hello community, here is the log from the commit of package menu-cache for openSUSE:Factory checked in at Wed Feb 24 02:18:54 CET 2010. -------- --- menu-cache/menu-cache.changes 2009-12-11 20:26:29.000000000 +0100 +++ /mounts/work_src_done/STABLE/menu-cache/menu-cache.changes 2010-02-17 16:53:43.000000000 +0100 @@ -1,0 +2,8 @@ +Wed Feb 17 15:48:41 UTC 2010 - andrea@opensuse.org + +- new upstream version 0.3.1 + * important bug fix + * menu-generation is now client side + * speed up and lower memory usage + +------------------------------------------------------------------- calling whatdependson for head-i586 Old: ---- menu-cache-0.2.6.tar.bz2 New: ---- menu-cache-0.3.1.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ menu-cache.spec ++++++ --- /var/tmp/diff_new_pack.rzB9IF/_old 2010-02-24 02:18:47.000000000 +0100 +++ /var/tmp/diff_new_pack.rzB9IF/_new 2010-02-24 02:18:47.000000000 +0100 @@ -1,7 +1,7 @@ # -# spec file for package menu-cache (Version 0.2.6) +# spec file for package menu-cache (Version 0.3.1) # -# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ Name: menu-cache -Version: 0.2.6 +Version: 0.3.1 Release: 1 License: GPL Source0: %{name}-%{version}.tar.bz2 @@ -37,7 +37,7 @@ License: GPL Group: Development/Libraries/C and C++ Requires: glib2-devel -Requires: %name +Requires: %name = %version Requires: libmenu-cache0 = %version Summary: Menu-cache Headers ++++++ menu-cache-0.2.6.tar.bz2 -> menu-cache-0.3.1.tar.bz2 ++++++ ++++ 1952 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/menu-cache-0.2.6/compile new/menu-cache-0.3.1/compile --- old/menu-cache-0.2.6/compile 2009-11-08 13:32:59.000000000 +0100 +++ new/menu-cache-0.3.1/compile 2010-02-16 14:20:30.000000000 +0100 @@ -1,7 +1,7 @@ #! /bin/sh # Wrapper for compilers which do not understand `-c -o'. -scriptversion=2009-04-28.21; # UTC +scriptversion=2009-10-06.20; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software # Foundation, Inc. @@ -124,9 +124,9 @@ ret=$? if test -f "$cofile"; then - mv "$cofile" "$ofile" + test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then - mv "${cofile}bj" "$ofile" + test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/menu-cache-0.2.6/configure.in new/menu-cache-0.3.1/configure.in --- old/menu-cache-0.2.6/configure.in 2009-11-08 16:05:08.000000000 +0100 +++ new/menu-cache-0.3.1/configure.in 2010-02-16 14:18:34.000000000 +0100 @@ -1,4 +1,4 @@ -AC_INIT([menu-cache], [0.2.6], +AC_INIT([menu-cache], [0.3.1], [http://lxde.org/]) AC_CONFIG_SRCDIR(menu-cache-gen/gmenu-tree.h) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/menu-cache-0.2.6/libmenu-cache/menu-cache.c new/menu-cache-0.3.1/libmenu-cache/menu-cache.c --- old/menu-cache-0.2.6/libmenu-cache/menu-cache.c 2009-11-08 16:04:14.000000000 +0100 +++ new/menu-cache-0.3.1/libmenu-cache/menu-cache.c 2010-02-16 14:17:51.000000000 +0100 @@ -19,6 +19,10 @@ * MA 02110-1301, USA. */ +/* NOTICE: This library is not MT-safe and should only be called from main thread. + * If you really need to use it in another thread, using mutex is needed, + * but the correct way to do this is unknown. */ + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -40,6 +44,12 @@ #include "menu-cache.h" +#ifdef G_ENABLE_DEBUG +#define DEBUG(...) g_debug(__VA_ARGS__) +#else +#define DEBUG(...) +#endif + struct _MenuCacheItem { guint n_ref; @@ -89,7 +99,6 @@ static guint server_watch = 0; static GHashTable* hash = NULL; - /* Don't call this API directly. Use menu_cache_lookup instead. */ static MenuCache* menu_cache_new( const char* cache_file ); @@ -284,58 +293,9 @@ MenuCache* menu_cache_new( const char* cache_file ) { MenuCache* cache; - struct stat st; - char line[4096]; - - FILE* f = fopen( cache_file, "r" ); - if( ! f ) - return NULL; - - if( fstat( fileno( f ), &st ) == -1 ) - { - fclose( f ); - return NULL; - } - - /* the first line is version number */ - if( fgets( line, G_N_ELEMENTS(line) ,f ) ) - { - int ver_maj, ver_min; - if( sscanf(line, "%d.%d", &ver_maj, &ver_min)< 2 ) - return NULL; - if( ver_maj != VER_MAJOR || ver_min != VER_MINOR ) - return NULL; - } - else - return NULL; - - /* the second line is menu name */ - if( ! fgets( line, G_N_ELEMENTS(line) ,f ) ) - return NULL; - cache = g_slice_new0( MenuCache ); - cache->cache_file = g_strdup( cache_file ); - /* cache->menu_file_path = g_strdup( strtok(line, "\n") ); */ - - /* get all used files */ - if( ! read_all_used_files( f, &cache->n_all_used_files, &cache->all_used_files ) ) - { - g_slice_free( MenuCache, cache ); - return NULL; - } - - /* read all known DEs */ - if( ! read_all_known_des( f, &cache->known_des ) ) - { - g_strfreev(cache->all_used_files); - g_slice_free( MenuCache, cache ); - return NULL; - } - cache->n_ref = 1; - cache->root_dir = (MenuCacheDir*)read_item( f, cache ); - fclose( f ); return cache; } @@ -347,18 +307,19 @@ void menu_cache_unref(MenuCache* cache) { - /* g_debug("cache_unref: %d", cache->n_ref); */ - if( g_atomic_int_dec_and_test( &cache->n_ref ) ) + /* DEBUG("cache_unref: %d", cache->n_ref); */ + --cache->n_ref; + if( cache->n_ref == 0 ) { unregister_menu_from_server( cache ); - /* g_debug("unregister to server"); */ + /* DEBUG("unregister to server"); */ g_hash_table_remove( hash, cache->menu_name ); if( g_hash_table_size(hash) == 0 ) { - /* g_debug("destroy hash"); */ + /* DEBUG("destroy hash"); */ g_hash_table_destroy(hash); - /* g_debug("disconnect from server"); */ + /* DEBUG("disconnect from server"); */ g_source_remove(server_watch); g_io_channel_unref(server_ch); server_fd = -1; @@ -368,9 +329,9 @@ if( G_LIKELY(cache->root_dir) ) { - /* g_debug("unref root dir"); */ + /* DEBUG("unref root dir"); */ menu_cache_item_unref( cache->root_dir ); - /* g_debug("unref root dir finished"); */ + /* DEBUG("unref root dir finished"); */ } g_free( cache->cache_file ); g_free( cache->menu_name ); @@ -378,6 +339,7 @@ g_strfreev( cache->all_used_files ); g_slice_free( MenuCache, cache ); } + } MenuCacheDir* menu_cache_get_root_dir( MenuCache* cache ) @@ -389,7 +351,7 @@ MenuCacheItem* menu_cache_item_ref(MenuCacheItem* item) { g_atomic_int_inc( &item->n_ref ); - /* g_debug("item_ref %s: %d -> %d", item->id, item->n_ref-1, item->n_ref); */ + /* DEBUG("item_ref %s: %d -> %d", item->id, item->n_ref-1, item->n_ref); */ return item; } @@ -475,7 +437,9 @@ return FALSE; } - menu_cache_item_unref( cache->root_dir ); + if(cache->root_dir) + menu_cache_item_unref( cache->root_dir ); + cache->root_dir = (MenuCacheDir*)read_item( f, cache ); fclose( f ); @@ -486,10 +450,10 @@ void menu_cache_item_unref(MenuCacheItem* item) { - /* g_debug("item_unref(%s): %d", item->id, item->n_ref); */ + /* DEBUG("item_unref(%s): %d", item->id, item->n_ref); */ if( g_atomic_int_dec_and_test( &item->n_ref ) ) { - /* g_debug("free item: %s", item->id); */ + /* DEBUG("free item: %s", item->id); */ g_free( item->id ); g_free( item->name ); g_free( item->comment ); @@ -500,7 +464,7 @@ if( item->parent ) { - /* g_debug("remove %s from parent %s", item->id, MENU_CACHE_ITEM(item->parent)->id); */ + /* DEBUG("remove %s from parent %s", item->id, MENU_CACHE_ITEM(item->parent)->id); */ /* remove ourselve from the parent node. */ item->parent->children = g_slist_remove(item->parent->children, item); } @@ -725,7 +689,7 @@ if( cond & (G_IO_ERR|G_IO_HUP) ) { reconnect: - g_debug("IO error %d, try to re-connect.", cond); + DEBUG("IO error %d, try to re-connect.", cond); g_io_channel_unref(ch); server_fd = -1; if( ! connect_server() ) @@ -737,14 +701,16 @@ GHashTableIter it; char* menu_name; MenuCache* cache; - g_debug("successfully restart server.\nre-register menus."); + DEBUG("successfully restart server.\nre-register menus."); /* re-register all menu caches */ + if(hash) { g_hash_table_iter_init(&it, hash); while(g_hash_table_iter_next(&it, (gpointer*)&menu_name, (gpointer*)&cache)) register_menu_to_server( menu_name, TRUE ); } + } return FALSE; } @@ -757,11 +723,11 @@ goto retry; if ( st != G_IO_STATUS_NORMAL || len < 4 ) { - g_debug("server IO error!!"); + DEBUG("server IO error!!"); goto reconnect; return FALSE; } - g_debug("server line: %s", line); + DEBUG("server line: %s", line); if( 0 == memcmp( line, "REL:", 4 ) ) /* reload */ { GHashTableIter it; @@ -769,20 +735,21 @@ MenuCache* cache; line[len - 1] = '\0'; char* menu_cache_id = line + 4; - g_debug("server ask us to reload cache: %s", menu_cache_id); + DEBUG("server ask us to reload cache: %s", menu_cache_id); + g_hash_table_iter_init(&it, hash); while(g_hash_table_iter_next(&it, (gpointer*)&menu_name, (gpointer*)&cache)) { if(0 == memcmp(cache->md5, menu_cache_id, 32)) { - g_debug("RELOAD!"); + DEBUG("RELOAD!"); menu_cache_reload(cache); break; } } + } - g_free( line ); } return TRUE; @@ -847,9 +814,10 @@ const char* xdg_data_home = g_getenv("XDG_DATA_HOME"); const char* xdg_cache_home = g_getenv("XDG_CACHE_HOME"); char* buf; - char md5[36]; + const char* md5; char* file_name; int len = 0, r; + GChecksum *sum; if( !xdg_cfg ) xdg_cfg = ""; @@ -868,7 +836,7 @@ while( strchr(langs[0], '.') ) ++langs; - buf = g_strdup_printf( "REG:%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", + buf = g_strdup_printf( "REG:%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t00000000000000000000000000000000\n", menu_name, *langs, xdg_cache_home, @@ -877,30 +845,33 @@ xdg_data, xdg_cfg_home, xdg_data_home ); - write( server_fd, buf, strlen(buf) ); - - while( (r=read(server_fd, md5 + len, 32 - len)) > 0 && len < 32 ) - len += r; - md5[32] = '\0'; + /* calculate the md5 sum of menu name + lang + all environment variables */ + sum = g_checksum_new(G_CHECKSUM_MD5); + len = strlen(buf); + g_checksum_update(sum, buf + 4, len - 38); + md5 = g_checksum_get_string(sum); + memcpy(buf + len - 33, md5, 32); + write( server_fd, buf, len ); + g_free( buf ); - if( r == -1 ) + if( re_register ) { - g_debug("server error!"); + g_checksum_free(sum); return NULL; } - g_free( buf ); - if( len != 32 || re_register ) - return NULL; file_name = g_build_filename( g_get_user_cache_dir(), "menus", md5, NULL ); - g_debug("cache file_name = %s", file_name); + DEBUG("cache file_name = %s", file_name); cache = menu_cache_new( file_name ); memcpy( cache->md5, md5, 32 ); cache->menu_name = g_strdup(menu_name); g_free( file_name ); + g_checksum_free(sum); /* md5 is also freed here */ + g_hash_table_insert( hash, g_strdup(menu_name), cache ); + return cache; } @@ -923,7 +894,10 @@ { cache = (MenuCache*)g_hash_table_lookup(hash, menu_name); if( cache ) + { + return menu_cache_ref(cache); + } } if( !connect_server() ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/menu-cache-0.2.6/libmenu-cache/menu-cache.h new/menu-cache-0.3.1/libmenu-cache/menu-cache.h --- old/menu-cache-0.2.6/libmenu-cache/menu-cache.h 2009-10-11 09:28:04.000000000 +0200 +++ new/menu-cache-0.3.1/libmenu-cache/menu-cache.h 2010-02-16 14:17:51.000000000 +0100 @@ -22,6 +22,10 @@ * MA 02110-1301, USA. */ +/* NOTICE: This library is not MT-safe and should only be called from main thread. + * If you really need to use it in another thread, using mutex is needed, + * but the correct way to do this is unknown. */ + #ifndef __MENU_CACHE_H__ #define __MENU_CACHE_H__ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/menu-cache-0.2.6/menu-cache-daemon/menu-cached.c new/menu-cache-0.3.1/menu-cache-daemon/menu-cached.c --- old/menu-cache-0.2.6/menu-cache-daemon/menu-cached.c 2009-11-08 16:04:46.000000000 +0100 +++ new/menu-cache-0.3.1/menu-cache-daemon/menu-cached.c 2010-02-16 14:20:08.000000000 +0100 @@ -1,7 +1,7 @@ /* * menu-cached.c * - * Copyright 2008 PCMan <pcman.tw@gmail.com> + * Copyright 2008 - 2010 PCMan <pcman.tw@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,6 +41,12 @@ #include <signal.h> #include <utime.h> +#ifdef G_ENABLE_DEBUG +#define DEBUG(...) g_debug(__VA_ARGS__) +#else +#define DEBUG(...) +#endif + typedef struct _Cache { int n_ref; @@ -70,11 +76,11 @@ static void cache_unref(Cache* cache) { --cache->n_ref; - /* g_debug("menu cache unrefed: ref_count=%d", cache->n_ref); */ + /* DEBUG("menu cache unrefed: ref_count=%d", cache->n_ref); */ if( cache->n_ref == 0 ) { int i; - /* g_debug("menu cache freed"); */ + /* DEBUG("menu cache freed"); */ g_slist_foreach( cache->clients, (GFunc)g_io_channel_unref, NULL ); g_slist_free( cache->clients ); for(i = 0; i < cache->n_files; ++i) @@ -97,7 +103,7 @@ } else if( cache->n_ref == 1 ) /* the last ref count is held by hash table */ { - /* g_debug("menu cache removed from hash"); */ + /* DEBUG("menu cache removed from hash"); */ g_hash_table_remove( hash, cache->md5 ); } } @@ -182,15 +188,15 @@ argv[4] = menu_name; argv[6] = cache_file; - /* g_debug("cmd: %s", g_strjoinv(" ", argv)); */ + /* DEBUG("cmd: %s", g_strjoinv(" ", argv)); */ /* run menu-cache-gen */ if( !g_spawn_sync(NULL, argv, NULL, 0, pre_exec, env, NULL, NULL, &status, NULL )) { - g_debug("error executing menu-cache-gen"); + DEBUG("error executing menu-cache-gen"); } - /* g_debug("exit status of menu-cache-gen: %d", status); */ + /* DEBUG("exit status of menu-cache-gen: %d", status); */ if( status != 0 ) return FALSE; @@ -201,7 +207,7 @@ { n_files = 0; files = NULL; - /* g_debug("error: read_all_used_files"); */ + /* DEBUG("error: read_all_used_files"); */ } fclose(f); } @@ -220,8 +226,8 @@ int i; GFile* gf; - /* g_debug("Re-generation of cache is needed!"); */ - /* g_debug("call menu-cache-gen to re-generate the cache"); */ + /* DEBUG("Re-generation of cache is needed!"); */ + /* DEBUG("call menu-cache-gen to re-generate the cache"); */ memcpy( buf, "REL:", 4 ); memcpy( buf + 4, cache->md5, 32 ); buf[36] = '\n'; @@ -244,7 +250,7 @@ if( ! regenerate_cache( cache->menu_name, cache->lang_name, cache_file, cache->env, &cache->n_files, &cache->files ) ) { - g_debug("regeneration of cache failed."); + DEBUG("regeneration of cache failed."); } cache->mons = g_realloc( cache->mons, sizeof(GFileMonitor*)*(cache->n_files+1) ); @@ -334,7 +340,7 @@ void on_file_changed( GFileMonitor* mon, GFile* gf, GFile* other, GFileMonitorEvent evt, Cache* cache ) { - /* g_debug("file %s is changed (%d).", g_file_get_path(gf), evt); */ + /* DEBUG("file %s is changed (%d).", g_file_get_path(gf), evt); */ /* if( mon != cache->cache_mon ) */ { /* Optimization: Some files in the dir are changed, but it @@ -370,7 +376,7 @@ * affect the content of our menu. */ gboolean in_cache = is_desktop_file_in_cache(cache, idx, base_name); - /* g_debug("in_cache = %d", in_cache); */ + /* DEBUG("in_cache = %d", in_cache); */ if( ! in_cache ) /* means this is a new file or previously hidden */ { GKeyFile* kf = g_key_file_new(); @@ -422,7 +428,7 @@ g_object_unref(gf); g_signal_connect( cache->cache_mon, "changed", G_CALLBACK(on_file_changed), cache); */ - g_debug("files are changed, but no re-generation is needed."); + DEBUG("files are changed, but no re-generation is needed."); return; } } @@ -513,17 +519,17 @@ } /* remove of previous socket file successful */ else - g_warning("removed previous socket file %s"); + g_warning("removed previous socket file %s", addr.sun_path); if(bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { - g_debug("Failed to bind to socket"); + DEBUG("Failed to bind to socket"); close(fd); return -1; } if(listen(fd, 30) < 0) { - g_debug( "Failed to listen to socket" ); + DEBUG( "Failed to listen to socket" ); close(fd); return -1; } @@ -536,7 +542,7 @@ char* md5; Cache* cache; GSList *l, *to_remove = NULL; - g_debug("client closed: %p", ch); + DEBUG("client closed: %p", ch); g_hash_table_iter_init (&it, hash); while( g_hash_table_iter_next (&it, (gpointer*)&md5, (gpointer*)&cache) ) { @@ -553,11 +559,11 @@ */ to_remove = g_slist_prepend( to_remove, cache ); cache->clients = g_slist_delete_link( cache->clients, l ); - g_debug("remove channel from cache"); + DEBUG("remove channel from cache"); g_io_channel_unref(ch); } } - /* g_debug("client closed"); */ + /* DEBUG("client closed"); */ g_slist_foreach( to_remove, (GFunc)cache_unref, NULL ); g_slist_free( to_remove ); } @@ -587,18 +593,18 @@ --len; line[len] = 0; - g_debug("line(%d) = %s", len, line); + DEBUG("line(%d) = %s", len, line); if( memcmp(line, "REG:", 4) == 0 ) { - GChecksum *sum; int status = 0, n_files, i; char *pline = line + 4; char *sep, *menu_name, *lang_name, *cache_dir, *cache_file; char **files; char **env; - len -= 4; + char reload_cmd[38] = "REL:"; + len -= 4; /* Format of received string, separated by '\t'. * Menu Name * Language Name @@ -608,9 +614,8 @@ * XDG_DATA_DIRS * XDG_CONFIG_HOME * XDG_DATA_HOME */ - sum = g_checksum_new(G_CHECKSUM_MD5); - g_checksum_update(sum, pline, len); - md5 = g_checksum_get_string(sum); + + md5 = pline + len - 32; /* the md5 hash of this menu */ cache = (Cache*)g_hash_table_lookup(hash, md5); if( !cache ) @@ -636,7 +641,7 @@ /* run menu-cache-gen */ if(! regenerate_cache( menu_name, lang_name, cache_file, env, &n_files, &files ) ) { - g_debug("regeneration of cache failed!!"); + DEBUG("regeneration of cache failed!!"); } } cache = g_slice_new0( Cache ); @@ -648,7 +653,7 @@ cache->env = env; cache->mons = g_new0(GFileMonitor*, n_files+1); /* create required file monitors */ - g_debug("%d files/dirs are monitored.", n_files); + DEBUG("%d files/dirs are monitored.", n_files); for( i = 0; i < n_files; ++i ) { gf = g_file_new_for_path( files[i] + 1 ); @@ -656,7 +661,7 @@ cache->mons[i] = g_file_monitor_directory( gf, 0, NULL, NULL ); else cache->mons[i] = g_file_monitor_file( gf, 0, NULL, NULL ); - /* g_debug("monitor: %s", g_file_get_path(gf)); */ + DEBUG("monitor: %s", g_file_get_path(gf)); g_signal_connect( cache->mons[i], "changed", on_file_changed, cache); g_object_unref(gf); } @@ -669,22 +674,27 @@ g_free(cache_file); g_hash_table_insert(hash, cache->md5, cache); - g_debug("new menu cache added to hash"); + DEBUG("new menu cache added to hash"); cache->n_ref = 1; } - /* g_debug("menu %s requested by client %d", md5, g_io_channel_unix_get_fd(ch)); */ + /* DEBUG("menu %s requested by client %d", md5, g_io_channel_unix_get_fd(ch)); */ ++cache->n_ref; cache->clients = g_slist_prepend( cache->clients, g_io_channel_ref(ch) ); - if( status == 0 ) - write( g_io_channel_unix_get_fd(ch), md5, 32 ); - else - write( g_io_channel_unix_get_fd(ch), "", 0 ); - g_checksum_free( sum ); + + /* generate a fake reload notification */ + DEBUG("fake reload!"); + memcpy(reload_cmd + 4, md5, 32); + + reload_cmd[36] = '\n'; + reload_cmd[37] = '\0'; + + DEBUG("reload command: %s", reload_cmd); + write(g_io_channel_unix_get_fd(ch), reload_cmd, 37); } else if( memcmp(line, "UNR:", 4) == 0 ) { md5 = line + 4; - g_debug("unregister: %s", md5); + DEBUG("unregister: %s", md5); cache = (Cache*)g_hash_table_lookup(hash, md5); if( cache ) { @@ -694,7 +704,7 @@ g_io_channel_unref(ch); } else - g_debug("bug! client is not found."); + DEBUG("bug! client is not found."); } g_free( line ); @@ -714,7 +724,7 @@ client = accept(server, &client_addr, &client_addrlen); if( client == -1 ) { - g_debug("accept error"); + DEBUG("accept error"); return TRUE; } @@ -722,7 +732,7 @@ g_io_add_watch( child, G_IO_PRI|G_IO_IN|G_IO_HUP|G_IO_ERR, on_client_data_in, NULL ); g_io_channel_set_close_on_unref( child, TRUE ); - /* g_debug("new client accepted"); */ + /* DEBUG("new client accepted"); */ return TRUE; } @@ -759,43 +769,43 @@ if( server_fd < 0 ) return 1; -#ifndef _DEBUG +#ifndef DISABLE_DAEMONIZE /* Become a daemon */ if ((pid = fork()) < 0) { - g_error("can't fork"); + g_error("can't fork"); } else if (pid != 0) { /* exit parent */ - exit(0); + exit(0); } /* change working directory to root, so previous working directory * can be unmounted */ if (chdir("/") < 0) { - g_error("can't change directory to /"); + g_error("can't change directory to /"); } open_max = sysconf (_SC_OPEN_MAX); for (i = 0; i < open_max; i++) { - /* don't hold open fd opened besides server socket */ - if (i != fd) - fcntl (i, F_SETFD, FD_CLOEXEC); + /* don't hold open fd opened besides server socket */ + if (i != fd) + fcntl (i, F_SETFD, FD_CLOEXEC); } /* /dev/null for stdin, stdout, stderr */ fd = open ("/dev/null", O_RDONLY); if (fd != -1) { - dup2 (fd, 0); - close (fd); + dup2 (fd, 0); + close (fd); } fd = open ("/dev/null", O_WRONLY); if (fd != -1) { - dup2 (fd, 1); - dup2 (fd, 2); - close (fd); + dup2 (fd, 1); + dup2 (fd, 2); + close (fd); } #endif ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org