Changeset 252 for trunk/src/sh_static.c


Ignore:
Timestamp:
Oct 12, 2009, 10:40:45 AM (15 years ago)
Author:
katerina
Message:

Add code to check for stale file records on close() and fclose(), fix sl_close() to handle open stream (ticket #163).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_static.c

    r170 r252  
    5454#include "sh_pthread.h"
    5555
     56extern  int sl_close_fd (const char * file, int line, int fd);
     57extern  int sl_fclose (const char * file, int line, FILE * fp);
     58
     59
    5660#ifndef _PATH_PASSWD
    5761#define _PATH_PASSWD "/etc/passwd"
     
    6064#define _PATH_GROUP "/etc/group"
    6165#endif
     66
     67#undef  FIL__
     68#define FIL__  _("sh_static.c")
    6269
    6370extern  int sl_strlcpy(char * dst, /*@null@*/const char * src, size_t siz);
     
    123130      }
    124131    } while (1);
    125     fclose(stream);
     132    sl_fclose(FIL__, __LINE__, stream);
    126133  }
    127134 
     
    171178      }
    172179    } while (1);
    173     fclose(stream);
     180    sl_fclose(FIL__, __LINE__, stream);
    174181  }
    175182 
     
    219226      }
    220227    } while (1);
    221     fclose(stream);
     228    sl_fclose(FIL__, __LINE__, stream);
    222229  }
    223230 
     
    267274      }
    268275    } while (1);
    269     fclose(stream);
     276    sl_fclose(FIL__, __LINE__, stream);
    270277  }
    271278 
     
    341348        SH_MUTEX_LOCK(pwf_lock);
    342349        if (pwf) {
    343                 fclose(pwf);
     350                sl_fclose(FIL__, __LINE__, pwf);
    344351                pwf = NULL;
    345352        }
     
    395402        SH_MUTEX_LOCK(grf_lock);
    396403        if (grf) {
    397                 fclose(grf);
     404                sl_fclose(FIL__, __LINE__, grf);
    398405                grf = NULL;
    399406        }
     
    498505                rv = setgroups(num_groups, group_list);
    499506        DO_CLOSE:
    500                 fclose(grf);
     507                sl_fclose(FIL__, __LINE__, grf);
    501508        }
    502509
     
    863870#include <arpa/inet.h>
    864871
    865 /* close()
     872/* sl_close_fd(FIL__, __LINE__, )
    866873 */
    867874#include <unistd.h>
     
    11851192        while (retries++ < MAX_RETRIES) {
    11861193                if (fd != -1)
    1187                         close(fd);
     1194                        sl_close_fd(FIL__, __LINE__, fd);
    11881195
    11891196                memset(packet, 0, PACKETSZ);
     
    13441351                DPRINTF("Answer type = |%d|\n", a->atype);
    13451352
    1346                 close(fd);
     1353                sl_close_fd(FIL__, __LINE__, fd);
    13471354
    13481355                if (outpacket)
     
    13901397fail:
    13911398        if (fd != -1)
    1392             close(fd);
     1399            sl_close_fd(FIL__, __LINE__, fd);
    13931400        if (lookup)
    13941401            free(lookup);
     
    15461553       
    15471554                if (action!=GETHOSTENT) {
    1548                         fclose(fp);
     1555                        sl_fclose(FIL__, __LINE__, fp);
    15491556                }
    15501557                return ret;
    15511558        }
    15521559        if (action!=GETHOSTENT) {
    1553                 fclose(fp);
     1560                sl_fclose(FIL__, __LINE__, fp);
    15541561        }
    15551562        return ret;
     
    16191626                        }
    16201627                }
    1621                 fclose(fp);
     1628                sl_fclose(FIL__, __LINE__, fp);
    16221629        } else {
    16231630            DPRINTF("failed to open %s\n", "resolv.conf");
Note: See TracChangeset for help on using the changeset viewer.