changeset 638:525c566741da

[gaim-migrate @ 648] small libfaim changes. no, it doesn't compile on solaris yet. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 08 Aug 2000 05:02:59 +0000
parents 8f0ba638d819
children 9a01b3fb1a9d
files libfaim/CHANGES libfaim/CHANGES.gaim libfaim/aim_conn.c libfaim/faim/aim.h src/oscar.c
diffstat 5 files changed, 58 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/libfaim/CHANGES	Tue Aug 08 02:22:54 2000 +0000
+++ b/libfaim/CHANGES	Tue Aug 08 05:02:59 2000 +0000
@@ -1,6 +1,13 @@
 
 No release numbers
 ------------------
+ - Tue Aug  8 04:25:35 UTC 2000
+   - Preserve subtype and priv after aim_conn_close
+
+ - Tue Aug  8 04:15:47 UTC 2000
+   - Fixed double-calling of faim_mutex_init
+   - conn->type preserved after aim_conn_close
+
  - Mon Jul 17 01:56:31 UTC 2000
    - Added 0004/000c callback (for message acknowledgments)
       - This goes with the AIM_IMFLAGS_ACK option that has been there
--- a/libfaim/CHANGES.gaim	Tue Aug 08 02:22:54 2000 +0000
+++ b/libfaim/CHANGES.gaim	Tue Aug 08 05:02:59 2000 +0000
@@ -1,3 +1,7 @@
+
+Tue Aug  8 04:59:55 UTC 2000 EWarmenhoven
+	- Small updates to libfaim. Hopefully this should fix a lot of the
+	  conn->type segfaults and pthread hangs.
 
 Fri Jul 21 19:47:36 UTC 2000 EWarmenhoven
 	- Direct IM. I think I ironed out most of the bugs. Now all I have
--- a/libfaim/aim_conn.c	Tue Aug 08 02:22:54 2000 +0000
+++ b/libfaim/aim_conn.c	Tue Aug 08 05:02:59 2000 +0000
@@ -55,6 +55,25 @@
   return newconn;
 }
 
+static void aim_conn_init(struct aim_conn_t *deadconn)
+{
+  if (!deadconn)
+    return;
+
+  deadconn->fd = -1;
+  deadconn->subtype = -1;
+  deadconn->type = -1;
+  deadconn->seqnum = 0;
+  deadconn->lastactivity = 0;
+  deadconn->forcedlatency = 0;
+  deadconn->handlerlist = NULL;
+  deadconn->priv = NULL;
+  faim_mutex_init(&deadconn->active, NULL);
+  faim_mutex_init(&deadconn->seqnum_lock, NULL);
+  
+  return;
+}
+
 void aim_conn_kill(struct aim_session_t *sess, struct aim_conn_t **deadconn)
 {
   struct aim_conn_t *cur;
@@ -83,7 +102,7 @@
   /* XXX: do we need this for txqueue too? */
   aim_rxqueue_cleanbyconn(sess, *deadconn);
 
-  aim_conn_close(*deadconn);
+  aim_conn_init(*deadconn);
   free(*deadconn);
   deadconn = NULL;
 
@@ -92,21 +111,32 @@
 
 void aim_conn_close(struct aim_conn_t *deadconn)
 {
+  int typesav = -1, subtypesav = -1;
+  void *privsav = NULL;
+
+  faim_mutex_destroy(&deadconn->active);
+  faim_mutex_destroy(&deadconn->seqnum_lock);
   if (deadconn->fd >= 3)
     close(deadconn->fd);
-  deadconn->fd = -1;
-  deadconn->type = -1;
-  deadconn->seqnum = 0;
-  deadconn->lastactivity = 0;
-  deadconn->forcedlatency = 0;
   if (deadconn->handlerlist)
     aim_clearhandlers(deadconn);
-  deadconn->handlerlist = NULL;
-  if (deadconn->priv)
+
+  typesav = deadconn->type;
+  subtypesav = deadconn->subtype;
+
+  if (deadconn->priv && (deadconn->type != AIM_CONN_TYPE_RENDEZVOUS)) {
     free(deadconn->priv);
-  deadconn->priv = NULL;
-  faim_mutex_init(&deadconn->active, NULL);
-  faim_mutex_init(&deadconn->seqnum_lock, NULL);
+    deadconn->priv = NULL;
+  }
+  privsav = deadconn->priv;
+
+  aim_conn_init(deadconn);
+
+  deadconn->type = typesav;
+  deadconn->subtype = subtypesav;
+  deadconn->priv = privsav;
+
+  return;
 }
 
 struct aim_conn_t *aim_getconn_type(struct aim_session_t *sess,
--- a/libfaim/faim/aim.h	Tue Aug 08 02:22:54 2000 +0000
+++ b/libfaim/faim/aim.h	Tue Aug 08 05:02:59 2000 +0000
@@ -43,6 +43,7 @@
 #define faim_mutex_init pthread_mutex_init
 #define faim_mutex_lock pthread_mutex_lock
 #define faim_mutex_unlock pthread_mutex_unlock
+#define faim_mutex_destroy pthread_mutex_destroy
 #elif defined(FAIM_USEFAKELOCKS)
 /*
  * For platforms without pthreads, we also assume
@@ -55,6 +56,7 @@
 #define faim_mutex_init(x, y) *x = 0
 #define faim_mutex_lock(x) *x = 1;
 #define faim_mutex_unlock(x) *x = 0;
+#define faim_mutex_destroy(x) *x = 0;
 #endif
 
 /* Portability stuff (DMP) */
--- a/src/oscar.c	Tue Aug 08 02:22:54 2000 +0000
+++ b/src/oscar.c	Tue Aug 08 05:02:59 2000 +0000
@@ -113,16 +113,14 @@
 				debug_print(_("connection error (rend)\n"));
 			}
 		} else {
-			char *direct = NULL;
-			if (conn->type == AIM_CONN_TYPE_RENDEZVOUS &&
-			    conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM)
-				direct = g_strdup(((struct aim_directim_priv *)conn->priv)->sn);
 			if (aim_get_command(gaim_sess, conn) >= 0) {
 				aim_rxdispatch(gaim_sess);
 			} else {
 				debug_print(_("connection error!\n"));
-				if (direct) {
-					struct conversation *cnv = find_conversation(direct);
+				if (conn->type == AIM_CONN_TYPE_RENDEZVOUS &&
+				    conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) {
+					struct conversation *cnv =
+						find_conversation(((struct aim_directim_priv *)conn->priv)->sn);
 					debug_print("connection error for directim\n");
 					if (cnv) {
 						make_direct(cnv, FALSE, NULL, 0);
@@ -138,7 +136,6 @@
 					gdk_input_remove(inpa);
 				}
 			}
-			if (direct) g_free(direct);
 		}
 	}
 }