]> arthur.barton.de Git - netatalk.git/commitdiff
increase the number of open forks.
authordidg <didg>
Wed, 28 Sep 2005 09:46:37 +0000 (09:46 +0000)
committerdidg <didg>
Wed, 28 Sep 2005 09:46:37 +0000 (09:46 +0000)
etc/afpd/fork.c
etc/afpd/fork.h
etc/afpd/ofork.c
include/atalk/adouble.h

index 1825bbfaf7d27cfd3eda91e786b16a93717d4b2d..1df39a0fd0762b149d76fd9f8b6a9caf218187fb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: fork.c,v 1.54 2005-04-28 20:49:43 bfernhomberg Exp $
+ * $Id: fork.c,v 1.55 2005-09-28 09:46:37 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -83,10 +83,10 @@ const u_int16_t     attrbits;
     vol = ofork->of_vol;
     dir = ofork->of_dir;
 
-    if (NULL == (path.u_name = mtoupath(vol, ofork->of_name, dir->d_did, utf8_encoding()))) {
+    if (NULL == (path.u_name = mtoupath(vol, of_name(ofork), dir->d_did, utf8_encoding()))) {
         return( AFPERR_MISC );
     }
-    path.m_name = ofork->of_name;
+    path.m_name = of_name(ofork);
     st = &path.st;
     if ( bitmap & ( (1<<FILPBIT_DFLEN) | (1<<FILPBIT_EXTDFLEN) | 
                     (1<<FILPBIT_FNUM) | (1 << FILPBIT_CDATE) | 
@@ -630,7 +630,7 @@ int ibuflen, *rbuflen;
             goto afp_setfork_err;
 
         if (ad_flush( ofork->of_ad, ADFLAGS_HF ) < 0) {
-            LOG(log_error, logtype_afpd, "afp_setforkparams(%s): ad_flush: %s", ofork->of_name, strerror(errno) );
+            LOG(log_error, logtype_afpd, "afp_setforkparams(%s): ad_flush: %s", of_name(ofork), strerror(errno) );
             return AFPERR_PARAM;
         }
     } else
@@ -638,7 +638,7 @@ int ibuflen, *rbuflen;
 
 #ifdef AFS
     if ( flushfork( ofork ) < 0 ) {
-        LOG(log_error, logtype_afpd, "afp_setforkparams(%s): flushfork: %s", ofork->of_name, strerror(errno) );
+        LOG(log_error, logtype_afpd, "afp_setforkparams(%s): flushfork: %s", of_name(ofork), strerror(errno) );
     }
 #endif /* AFS */
 
@@ -785,7 +785,7 @@ struct ofork        *of;
 
     if ( ad_hfileno( of->of_ad ) == -1 || !memcmp( ufinderi, ad_entry( of->of_ad, ADEID_FINDERI),8)) {
         /* no resource fork or no finderinfo, use our files extension mapping */
-        if (!( em = getextmap( of->of_name )) || memcmp( "TEXT", em->em_type, sizeof( em->em_type ))) {
+        if (!( em = getextmap( of_name(of) )) || memcmp( "TEXT", em->em_type, sizeof( em->em_type ))) {
             return 0;
         } 
         /* file type is TEXT */
@@ -809,7 +809,7 @@ static __inline__ ssize_t read_file(struct ofork *ofork, int eid,
 
     cc = ad_read(ofork->of_ad, eid, offset, rbuf, *rbuflen);
     if ( cc < 0 ) {
-        LOG(log_error, logtype_afpd, "afp_read(%s): ad_read: %s", ofork->of_name, strerror(errno) );
+        LOG(log_error, logtype_afpd, "afp_read(%s): ad_read: %s", of_name(ofork), strerror(errno) );
         *rbuflen = 0;
         return( AFPERR_PARAM );
     }
@@ -979,7 +979,7 @@ int     is64;
                 if (errno == EINVAL || errno == ENOSYS)
                     goto afp_read_loop;
                 else {
-                    LOG(log_error, logtype_afpd, "afp_read(%s): ad_readfile: %s", ofork->of_name, strerror(errno));
+                    LOG(log_error, logtype_afpd, "afp_read(%s): ad_readfile: %s", of_name(ofork), strerror(errno));
                     goto afp_read_exit;
                 }
             }
@@ -1024,7 +1024,7 @@ afp_read_loop:
         goto afp_read_done;
 
 afp_read_exit:
-        LOG(log_error, logtype_afpd, "afp_read(%s): %s", ofork->of_name, strerror(errno));
+        LOG(log_error, logtype_afpd, "afp_read(%s): %s", of_name(ofork), strerror(errno));
         dsi_readdone(dsi);
         ad_tmplock(ofork->of_ad, eid, ADLOCK_CLR, saveoff, savereqcount,ofork->of_refnum);
         obj->exit(EXITERR_CLNT);
@@ -1096,7 +1096,7 @@ int       ibuflen _U_, *rbuflen;
     }
 
     if ( flushfork( ofork ) < 0 ) {
-        LOG(log_error, logtype_afpd, "afp_flushfork(%s): %s", ofork->of_name, strerror(errno) );
+        LOG(log_error, logtype_afpd, "afp_flushfork(%s): %s", of_name(ofork), strerror(errno) );
     }
 
     return( AFP_OK );
@@ -1113,7 +1113,7 @@ struct ofork      *ofork;
     if ( ad_dfileno( ofork->of_ad ) != -1 &&
             fsync( ad_dfileno( ofork->of_ad )) < 0 ) {
         LOG(log_error, logtype_afpd, "flushfork(%s): dfile(%d) %s",
-            ofork->of_name, ad_dfileno(ofork->of_ad), strerror(errno) );
+            of_name(ofork), ad_dfileno(ofork->of_ad), strerror(errno) );
         err = -1;
     }
 
@@ -1139,7 +1139,7 @@ struct ofork      *ofork;
 
         if (err < 0)
             LOG(log_error, logtype_afpd, "flushfork(%s): hfile(%d) %s",
-                ofork->of_name, ad_hfileno(ofork->of_ad), strerror(errno) );
+                of_name(ofork), ad_hfileno(ofork->of_ad), strerror(errno) );
     }
 
     return( err );
@@ -1162,7 +1162,7 @@ int       ibuflen _U_, *rbuflen;
         return( AFPERR_PARAM );
     }
     if ( of_closefork( ofork ) < 0 ) {
-        LOG(log_error, logtype_afpd, "afp_closefork(%s): of_closefork: %s", ofork->of_name, strerror(errno) );
+        LOG(log_error, logtype_afpd, "afp_closefork(%s): of_closefork: %s", of_name(ofork), strerror(errno) );
         return( AFPERR_PARAM );
     }
 
@@ -1198,7 +1198,7 @@ static __inline__ ssize_t write_file(struct ofork *ofork, int eid,
         case ENOSPC :
             return( AFPERR_DFULL );
         default :
-            LOG(log_error, logtype_afpd, "afp_write(%s): ad_write: %s", ofork->of_name, strerror(errno) );
+            LOG(log_error, logtype_afpd, "afp_write(%s): ad_write: %s", of_name(ofork), strerror(errno) );
             return( AFPERR_PARAM );
         }
     }
@@ -1440,7 +1440,7 @@ int       ibuflen _U_, *rbuflen;
 
     if ( ad_hfileno( ofork->of_ad ) != -1 ) {
         if ( ad_refresh( ofork->of_ad ) < 0 ) {
-            LOG(log_error, logtype_afpd, "getforkparams(%s): ad_refresh: %s", ofork->of_name, strerror(errno) );
+            LOG(log_error, logtype_afpd, "getforkparams(%s): ad_refresh: %s", of_name(ofork), strerror(errno) );
             return( AFPERR_PARAM );
         }
     }
index 785071987310be644cf58668c327c25ad7f23ef8..5a6bdc011b5e896ed66fcb7c6601d15f46e292b3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: fork.h,v 1.9 2005-04-28 20:49:43 bfernhomberg Exp $
+ * $Id: fork.h,v 1.10 2005-09-28 09:46:37 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -25,8 +25,6 @@ struct ofork {
     struct adouble     *of_ad;
     struct vol          *of_vol;
     struct dir         *of_dir;
-    char               *of_name;
-    int                 of_namelen;
 
     u_int16_t           of_refnum;
     int                 of_flags;
@@ -53,6 +51,7 @@ struct ofork {
 #define AFPFORK_ACCWR   (1<<5)
 #define AFPFORK_ACCMASK (AFPFORK_ACCRD | AFPFORK_ACCWR)
 
+#define of_name(a) (a)->of_ad->ad_m_name
 /* in ofork.c */
 extern struct ofork *of_alloc    __P((struct vol *, struct dir *,
                                                       char *, u_int16_t *, const int,
index 0c8c5feb8f8be39a83d1c6b24c392aeeb9186a4a..e4ec59b5f2d5943d4843ab5b5408f43338c3532f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ofork.c,v 1.23 2005-07-20 21:23:52 didg Exp $
+ * $Id: ofork.c,v 1.24 2005-09-28 09:46:37 didg Exp $
  *
  * Copyright (c) 1996 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -80,7 +80,7 @@ FILE  *f;
 
     for ( ofrefnum = 0; ofrefnum < nforks; ofrefnum++ ) {
         if ( oforks[ ofrefnum ] != NULL ) {
-            fprintf( f, "%hu <%s>\n", ofrefnum, oforks[ ofrefnum ]->of_name);
+            fprintf( f, "%hu <%s>\n", ofrefnum, of_name(oforks[ ofrefnum ]);
         }
     }
 }
@@ -109,6 +109,7 @@ struct dir *olddir, *newdir;
 const char *oldpath _U_, *newpath;
 {
     struct ofork *of, *next, *d_ofork;
+    int done = 0;
 
     if (!s_of)
         return AFP_OK;
@@ -120,7 +121,10 @@ const char *oldpath _U_, *newpath;
         if (vol == of->of_vol && olddir == of->of_dir &&
                 s_of->key.dev == of->key.dev && 
                 s_of->key.inode == of->key.inode ) {
-            strlcpy( of->of_name, newpath, of->of_namelen);
+           if (!done) {
+               strlcpy( of_name(of), newpath, of->of_ad->ad_m_namelen);
+               done = 1;
+           }
             if (newdir != olddir) {
                 of->of_d_prev->of_d_next = of->of_d_next;
                 of->of_d_next->of_d_prev = of->of_d_prev;
@@ -162,7 +166,7 @@ struct stat     *st;
     int                        i;
 
     if (!oforks) {
-        nforks = (getdtablesize() - 10) / 2;
+        nforks = getdtablesize() - 10;
        /* protect against insane ulimit -n */
         nforks = min(nforks, 0xffff);
         oforks = (struct ofork **) calloc(nforks, sizeof(struct ofork *));
@@ -210,23 +214,11 @@ struct stat     *st;
     }
     of = oforks[of_refnum];
 
-    /* here's the deal: we allocate enough for the standard mac file length.
-     * in the future, we'll reallocate in fairly large jumps in case
-     * of long unicode names */
-    of->of_namelen = 255 +1;
-    if (( of->of_name =(char *)malloc( of->of_namelen )) == NULL ) {
-        LOG(log_error, logtype_afpd, "of_alloc: malloc: %s", strerror(errno) );
-        free(of);
-        oforks[ of_refnum ] = NULL;
-        return NULL;
-    }
-
     /* see if we need to allocate space for the adouble struct */
     if (!ad) {
         ad = malloc( sizeof( struct adouble ) );
         if (!ad) {
             LOG(log_error, logtype_afpd, "of_alloc: malloc: %s", strerror(errno) );
-            free(of->of_name);
             free(of);
             oforks[ of_refnum ] = NULL;
             return NULL;
@@ -235,6 +227,19 @@ struct stat     *st;
         /* initialize to zero. This is important to ensure that
            ad_open really does reinitialize the structure. */
         ad_init(ad, vol->v_adouble, vol->v_ad_options);
+
+        ad->ad_m_namelen = 255 +1;
+        /* here's the deal: we allocate enough for the standard mac file length.
+         * in the future, we'll reallocate in fairly large jumps in case
+         * of long unicode names */
+        if (( ad->ad_m_name =(char *)malloc( ad->ad_m_namelen )) == NULL ) {
+            LOG(log_error, logtype_afpd, "of_alloc: malloc: %s", strerror(errno) );
+            free(ad);
+            free(of);
+            oforks[ of_refnum ] = NULL;
+            return NULL;
+        }
+        strlcpy( ad->ad_m_name, path, ad->ad_m_namelen);
     } else {
         /* Increase the refcount on this struct adouble. This is
            decremented again in oforc_dealloc. */
@@ -255,7 +260,6 @@ struct stat     *st;
         d_ofork->of_d_prev = of;
     }
 
-    strlcpy( of->of_name, path, of->of_namelen);
     *ofrefnum = refnum;
     of->of_refnum = refnum;
     of->key.dev = st->st_dev;
@@ -361,12 +365,12 @@ struct ofork      *of;
     }
 
     oforks[ of->of_refnum % nforks ] = NULL;
-    free( of->of_name );
 
     /* decrease refcount */
     of->of_ad->ad_refcount--;
 
     if ( of->of_ad->ad_refcount <= 0) {
+        free( of->of_ad->ad_m_name );
         free( of->of_ad);
     } else {/* someone's still using it. just free this user's locks */
         ad_unlock(of->of_ad, of->of_refnum);
index 8a04a23ac80a67dbfa119701df4cc3273398d6ed..271d59eaac27cbb067f2ff769248f92ba8a2cbe4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: adouble.h,v 1.28 2005-05-25 18:24:24 didg Exp $
+ * $Id: adouble.h,v 1.29 2005-09-28 09:46:37 didg Exp $
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
  *
@@ -254,6 +254,9 @@ struct adouble {
     off_t               ad_rlen;     /* ressource fork len with AFP 3.0
                                         the header parameter size is too small.
                                      */
+    char                *ad_m_name;   /* mac name for open fork */
+    int                 ad_m_namelen;
+
     char                *(*ad_path)(const char *, int);
     int                 (*ad_mkrf)(char *);