--- multisync/src/syncengine.c	2003-08-25 23:25:08.000000000 +0300
+++ multisync.modified/src/syncengine.c	2003-09-01 20:57:03.000000000 +0300
@@ -470,7 +470,13 @@
   }    
 
   sync_init(thissync);
-  
+
+  if (thissync->localclient==0) {
+    fprintf(stderr, "The local client [%s] has failed to load!\n", thissync->localname);
+    fprintf(stderr, "What should we do now? This is going to fail. Aborting!\n");
+    return NULL;
+  }
+
   localalwaysconn = (gboolean) CALL_PLUGIN(thissync->localclient, 
 					   "always_connected",());
   if (localalwaysconn) {
@@ -799,7 +805,12 @@
   
   dd(printf("Syncthread: Exiting.\n"));
   if (localconn) {
+    char *ptr;
     CALL_PLUGIN_ASYNC(thissync->localclient, "sync_disconnect", (localconn));
+    ptr=dlerror();
+    if (ptr != 0) {
+      printf("ERROR: Failed to request disconnection from module: %s (Error=%s)\n", thissync->localname, ptr);
+    }
     ret = sync_wait_msg(&thissync->msg_callret, NULL);
   }
   if (remoteconn) {
@@ -1583,6 +1594,7 @@
 
 void read_pluginlist() {
   DIR *dir;
+  char *ptr;
 
   if ((dir = opendir(PLUGINDIR))) {
     struct dirent *de = NULL;
@@ -1617,17 +1629,29 @@
 				  "version or remove the plugin.", name);
 	    sync_async_msg(msg);
 	    g_free(msg);
+	    if (mod) {
+              dlclose(mod);
+	    }
 	  } else {
 	    plugin = g_malloc0(sizeof(sync_plugin));
 	    g_assert(plugin);
 	    plugin->plugin = mod;
 	    plugin->longname = CALL_PLUGIN(plugin, "long_name", ());
+            ptr=dlerror();
+            if (ptr != 0) {
+              printf("ERROR: Failed to load plugin: %s! (Error=%s, missing long_name-symbol)\n", name, ptr);
+              dlclose(mod);
+              continue;
+            }
+    
 	    plugin->shortname = CALL_PLUGIN(plugin, "short_name", ());
 	    CALL_PLUGIN(plugin, "plugin_init", ());
 	    dd(printf("Plugin found: %s\n", plugin->longname));
 	    pluginlist = g_list_append(pluginlist, plugin);
 	  }
-	} 
+	} else {
+          dd(printf("Failed to load plugin: %s (Error=%s)\n", name, dlerror()));
+        }
       }
     }
     closedir(dir);
