[hackers] [libixp] Free the Fid freelist on unmount.

From: Kris Maglione <jg_AT_suckless.org>
Date: Fri Jun 01 20:44:02 2007

changeset: 60:2c1d8bcb12ac
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Fri Jun 01 14:38:08 2007 -0400
summary: Free the Fid freelist on unmount.

diff -r 21aed24cae3a -r 2c1d8bcb12ac Makefile
--- a/Makefile Fri Jun 01 13:57:38 2007 -0400
+++ b/Makefile Fri Jun 01 14:38:08 2007 -0400
@@ -7,3 +7,4 @@ DIRS = libixp \
         man
 
 include ${ROOT}/mk/dir.mk
+
diff -r 21aed24cae3a -r 2c1d8bcb12ac config.mk
--- a/config.mk Fri Jun 01 13:57:38 2007 -0400
+++ b/config.mk Fri Jun 01 14:38:08 2007 -0400
@@ -13,6 +13,7 @@ LIBS = -L/usr/lib -lc
 LIBS = -L/usr/lib -lc
 
 # Flags
+include ${ROOT}/mk/gcc.mk
 CFLAGS = -g -Wall ${INCS} -DVERSION=\"${VERSION}\"
 LDFLAGS = -g ${LIBS}
 
diff -r 21aed24cae3a -r 2c1d8bcb12ac include/ixp.h
--- a/include/ixp.h Fri Jun 01 13:57:38 2007 -0400
+++ b/include/ixp.h Fri Jun 01 14:38:08 2007 -0400
@@ -30,10 +30,10 @@ char *errstr;
 #define nil ((void*)0)
 
 #define IXP_VERSION "9P2000"
-#define IXP_NOTAG ((ushort)~0) /*Dummy tag */
+#define IXP_NOTAG ((ushort)~0) /* Dummy tag */
+#define IXP_NOFID (~0U)
 
 enum {
- IXP_NOFID = ~0U,
         IXP_MAX_VERSION = 32,
         IXP_MAX_MSG = 65535,
         IXP_MAX_ERROR = 128,
diff -r 21aed24cae3a -r 2c1d8bcb12ac libixp/client.c
--- a/libixp/client.c Fri Jun 01 13:57:38 2007 -0400
+++ b/libixp/client.c Fri Jun 01 14:38:08 2007 -0400
@@ -30,18 +30,14 @@ getfid(IxpClient *c) {
         IxpCFid *temp;
         uint i;
 
- if(!c->freefid) {
- i = 15;
+ temp = c->freefid;
+ if(temp != nil)
+ c->freefid = temp->next;
+ else {
                 temp = ixp_emallocz(sizeof(IxpCFid) * i);
- while(i--) {
- temp->client = c;
- temp->fid = ++c->lastfid;
- temp->next = c->freefid;
- c->freefid = temp++;
- }
- }
- temp = c->freefid;
- c->freefid = temp->next;
+ temp->client = c;
+ temp->fid = ++c->lastfid;
+ }
         temp->next = nil;
         temp->open = 0;
         return temp;
@@ -89,8 +85,15 @@ dofcall(IxpClient *c, Fcall *fcall) {
 
 void
 ixp_unmount(IxpClient *c) {
+ IxpCFid *f;
+
         shutdown(c->fd, SHUT_RDWR);
         close(c->fd);
+
+ while((f = c->freefid)) {
+ c->freefid = f->next;
+ free(f);
+ }
         free(c->msg.data);
         free(c);
 }
diff -r 21aed24cae3a -r 2c1d8bcb12ac libixp/server.c
--- a/libixp/server.c Fri Jun 01 13:57:38 2007 -0400
+++ b/libixp/server.c Fri Jun 01 14:38:08 2007 -0400
@@ -52,12 +52,12 @@ prepare_select(IxpServer *s) {
         IxpConn *c;
 
         FD_ZERO(&s->rd);
- for(c = s->conn; c; c = c->next) {
- if(s->maxfd < c->fd)
- s->maxfd = c->fd;
- if(c->read)
+ for(c = s->conn; c; c = c->next)
+ if(c->read) {
+ if(s->maxfd < c->fd)
+ s->maxfd = c->fd;
                         FD_SET(c->fd, &s->rd);
- }
+ }
 }
 
 static void
Received on Fri Jun 01 2007 - 20:44:02 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:57:14 UTC