|
From: <mla...@us...> - 2008-01-01 05:59:20
|
Revision: 371
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=371&view=rev
Author: mlampard
Date: 2007-12-31 21:59:21 -0800 (Mon, 31 Dec 2007)
Log Message:
-----------
Add Solaris support. Improve plugin loader robustness. Log build OS and gcc version in debug mode.
Modified Paths:
--------------
trunk/g15daemon-wip/ChangeLog
trunk/g15daemon-wip/Makefile.am
trunk/g15daemon-wip/configure.in
trunk/g15daemon-wip/g15daemon/g15_plugins.c
trunk/g15daemon-wip/g15daemon/main.c
Modified: trunk/g15daemon-wip/ChangeLog
===================================================================
--- trunk/g15daemon-wip/ChangeLog 2008-01-01 02:44:40 UTC (rev 370)
+++ trunk/g15daemon-wip/ChangeLog 2008-01-01 05:59:21 UTC (rev 371)
@@ -127,5 +127,12 @@
- Bugfix: Fix autoconf autodetect bugs re uinput plugin.
- Feature: If autodetection of uinput fails, configure now has a
--disable-uinput override.
-- Feature: WIP should now _compile_ on Linux, MacOSX, and Solaris. Solaris
- support is currently in progress.
+- Feature: WIP should now compile and run on Linux, MacOSX, and Solaris (v10+).
+ Only Linux and Solaris have been tested.
+- Debug: Add more debugging to plugin loader.
+- Debug: Log build date,OS and GCC version.
+- Feature: Plugin loader will now use DEEP_BIND if available, hopefully
+ resolving conflicts on OS's that support it.
+- Feature: Solaris support. Requires some end-user changes to the usb
+ stack at the moment. Documentation coming soon.
+- BugFix: Plugin loader is now much more robust.
Modified: trunk/g15daemon-wip/Makefile.am
===================================================================
--- trunk/g15daemon-wip/Makefile.am 2008-01-01 02:44:40 UTC (rev 370)
+++ trunk/g15daemon-wip/Makefile.am 2008-01-01 05:59:21 UTC (rev 371)
@@ -2,6 +2,7 @@
SUBDIRS = libg15daemon_client g15daemon plugins
INCLUDES = -I$(top_srcdir)/libg15daemon_client -I$(top_srcdir)/g15daemon
+
EXTRA_DIST = debian contrib Documentation lang-bindings patches rpm README.usage FAQ LICENSE images
docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
Modified: trunk/g15daemon-wip/configure.in
===================================================================
--- trunk/g15daemon-wip/configure.in 2008-01-01 02:44:40 UTC (rev 370)
+++ trunk/g15daemon-wip/configure.in 2008-01-01 05:59:21 UTC (rev 371)
@@ -13,12 +13,11 @@
AM_INIT_AUTOMAKE()
AC_CONFIG_HEADER([config.h])
-
AC_LIBTOOL_DLOPEN
+
# Checks for programs.
AC_PROG_CC
AC_PROG_LIBTOOL
-AC_PROG_RANLIB
# Checks for libraries.
AC_CHECK_LIB([g15], [initLibG15],,AC_MSG_ERROR(["libg15 (or its devel package) not found. please install it"]))
Modified: trunk/g15daemon-wip/g15daemon/g15_plugins.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/g15_plugins.c 2008-01-01 02:44:40 UTC (rev 370)
+++ trunk/g15daemon-wip/g15daemon/g15_plugins.c 2008-01-01 05:59:21 UTC (rev 371)
@@ -52,13 +52,35 @@
void * handle;
char * error;
-
+ static int deepbind = 0;
+
int mode = library==1?RTLD_GLOBAL:RTLD_LOCAL;
+#ifdef RTLD_DEEPBIND
+ mode|=RTLD_DEEPBIND; /* set ordering of symbols so plugin uses its
+ own symbols in preference to ours */
+ if(!deepbind)
+ g15daemon_log(LOG_ERR,"G15Daemon Plugin_Loader - DEEPBIND Flag available. Using it.");
+ deepbind=1;
+#endif
+
+ g15daemon_log(LOG_ERR,"PRELOADING %s",name);
+ /* remove any pending errors */
+ dlerror();
+
+ handle = dlopen (name,RTLD_LAZY | mode | RTLD_NODELETE);
+ dlclose(handle);
+ dlerror();
- handle = dlopen (name,RTLD_NOW | mode);
+ handle = dlopen (name,RTLD_NOW | mode | RTLD_NOLOAD);
+ if(!handle) { /* FIXME: retry once more if load failed */
+ dlerror();
+ g15daemon_log(LOG_ERR, "Initialisation Failed. Retrying..");
+ handle = dlopen (name, RTLD_LAZY | mode );
+ }
+
if ((error = dlerror()) != NULL) {
- g15daemon_log (LOG_ERR, "%s\n", error);
+ g15daemon_log (LOG_ERR, "Plugin_Loader - Error loading %s - %s\n", name, error);
return(NULL);
}
@@ -67,7 +89,12 @@
int g15daemon_dlclose_plugin(void *handle) {
+ char * error;
dlclose(handle);
+ error = dlerror();
+ if(error != NULL)
+ g15daemon_log(LOG_ERR, "Error from dlclose %s\n",error);
+
return 0;
}
@@ -144,15 +171,17 @@
void *handle = plugin_args->plugin_handle;
if(plugin_args->info->plugin_run!=NULL||plugin_args->info->event_handler!=NULL) {
- g15daemon_log(LOG_ERR,"registered plugin \"%s\"",info->name);
+ g15daemon_log(LOG_ERR,"Plugin \"%s\" boot successful.",info->name);
} else {
return NULL;
}
if(plugin_args->type == G15_PLUGIN_LCD_CLIENT){
+ g15daemon_log(LOG_ERR,"Starting plugin \"%s\" in standard mode\n",info->name);
run_lcd_client(plugin_args);
}
else if(plugin_args->type == G15_PLUGIN_CORE_OS_KB||plugin_args->type == G15_PLUGIN_LCD_SERVER) {
+ g15daemon_log(LOG_ERR,"Starting plugin \"%s\" in advanced mode\n",info->name);
run_advanced_client(plugin_args);
}
@@ -173,14 +202,20 @@
pthread_t client_connection;
pthread_attr_t attr;
lcdnode_t *clientnode;
-
+ char *error_str;
+
if((plugin_handle = g15daemon_dlopen_plugin(filename,G15_PLUGIN_NONSHARED))!=NULL) {
plugin_t *plugin_args=malloc(sizeof(plugin_t));
plugin_args->info = dlsym(plugin_handle, "g15plugin_info");
+ g15daemon_log(LOG_INFO, "Booting plugin...");
- dlerror();
+ error_str=dlerror();
+
+ if(error_str!=NULL)
+ g15daemon_log(LOG_ERR,"g15_plugin_load: %s %s\n",filename,error_str);
+
if(!plugin_args->info) { /* if it doesnt have a valid struct, we should just load it as a library... but we dont at the moment FIXME */
- g15daemon_log(LOG_ERR,"%s is not a valid g15daemon plugin\n",filename);
+ g15daemon_log(LOG_ERR,"%s is not a valid g15daemon plugin. Unloading\n",filename);
g15daemon_dlclose_plugin(plugin_handle);
dlerror();
return -1;
@@ -245,13 +280,13 @@
strcpy(pluginname, plugin_directory);
strncat(pluginname,"/",1);
strncat(pluginname,ep->d_name,200);
- g15daemon_log(LOG_INFO, "Loading plugin %s",pluginname);
g15_plugin_load (masterlist, pluginname);
g15daemon_msleep(20);
}
}
(void) closedir (directory);
+ g15daemon_log(LOG_WARNING,"All available plugins loaded.");
}
else
- perror ("Couldn't open the directory");
+ g15daemon_log (LOG_ERR,"Unable to open the directory: %s",plugin_directory);
}
Modified: trunk/g15daemon-wip/g15daemon/main.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/main.c 2008-01-01 02:44:40 UTC (rev 370)
+++ trunk/g15daemon-wip/g15daemon/main.c 2008-01-01 05:59:21 UTC (rev 371)
@@ -176,12 +176,11 @@
unsigned int keypresses = 0;
int retval = 0;
static int lastkeys = 0;
+
while (!leaving) {
-
pthread_mutex_lock(&g15lib_mutex);
retval = getPressedKeys(&keypresses, 20);
pthread_mutex_unlock(&g15lib_mutex);
-
/* every 2nd packet contains the codes we want.. immediately try again */
while (retval == G15_ERROR_TRY_AGAIN){
pthread_mutex_lock(&g15lib_mutex);
@@ -206,10 +205,8 @@
}
pthread_mutex_unlock(&g15lib_mutex);
}
-
g15daemon_msleep(40);
}
-
return NULL;
}
@@ -259,7 +256,6 @@
}
pthread_mutex_unlock(&lcdlist_mutex);
-
g15daemon_msleep(5);
}
return NULL;
@@ -363,10 +359,13 @@
}
}
if(g15daemon_debug){
- fprintf(stderr, "G15Daemon CMDLINE ARGS: ");
- for(i=1;i<argc;i++)
- fprintf(stderr, "%s ",argv[i]);
- fprintf(stderr,"\n");
+ g15daemon_log(LOG_INFO, "G15Daemon %s Build Date: %s",PACKAGE_VERSION,BUILD_DATE);
+ g15daemon_log(LOG_INFO, "Build OS: %s",BUILD_OS_NAME);
+ g15daemon_log(LOG_INFO, "With compiler: %s",COMPILER_VERSION);
+ fprintf(stderr, "G15Daemon CMDLINE ARGS: ");
+ for(i=1;i<argc;i++)
+ fprintf(stderr, "%s ",argv[i]);
+ fprintf(stderr,"\n");
}
if(uf_return_running()>=0) {
g15daemon_log(LOG_ERR,"G15Daemon already running.. Exiting");
@@ -442,19 +441,22 @@
if(!cycle_cmdline_override){
cycle_key = 1==g15daemon_cfg_read_bool(global_cfg,"Use MR as Cycle Key",0)?G15_KEY_MR:G15_KEY_L1;
}
+#ifndef OSTYPE_SOLARIS
/* all other processes/threads should be seteuid nobody */
if(nobody!=NULL) {
seteuid(nobody->pw_uid);
setegid(nobody->pw_gid);
}
+#endif
pthread_mutex_init(&g15lib_mutex, NULL);
pthread_attr_init(&attr);
+
pthread_attr_setstacksize(&attr,512*1024); /* set stack to 512k - dont need 8Mb !! */
-
if (pthread_create(&keyboard_thread, &attr, keyboard_watch_thread, lcdlist) != 0) {
g15daemon_log(LOG_ERR,"Unable to create keyboard listener thread. Exiting");
goto exitnow;
}
+
pthread_attr_setstacksize(&attr,128*1024);
if (pthread_create(&lcd_thread, &attr, lcd_draw_thread, lcdlist) != 0) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|