Changeset 2320 for zzuf/trunk/src/lib-fd.c
- Timestamp:
- Apr 26, 2008, 2:24:57 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/src/lib-fd.c
r1864 r2320 81 81 #if defined HAVE_OPEN64 82 82 static int (*ORIG(open64)) (const char *file, int oflag, ...); 83 #endif 84 #if defined HAVE_DUP 85 static int (*ORIG(dup)) (int oldfd); 86 #endif 87 #if defined HAVE_DUP2 88 static int (*ORIG(dup2)) (int oldfd, int newfd); 83 89 #endif 84 90 #if defined HAVE_ACCEPT … … 172 178 #endif 173 179 180 #if defined HAVE_DUP 181 int NEW(dup)(int oldfd) 182 { 183 int ret; 184 185 LOADSYM(dup); 186 ret = ORIG(dup)(oldfd); 187 if(!_zz_ready || _zz_islocked(-1) || !_zz_iswatched(oldfd) 188 || !_zz_isactive(oldfd)) 189 return ret; 190 191 if(ret >= 0) 192 { 193 debug("%s(%i) = %i", __func__, oldfd, ret); 194 _zz_register(ret); 195 } 196 197 return ret; 198 } 199 #endif 200 201 #if defined HAVE_DUP2 202 int NEW(dup2)(int oldfd, int newfd) 203 { 204 int ret; 205 206 LOADSYM(dup2); 207 ret = ORIG(dup2)(oldfd, newfd); 208 if(!_zz_ready || _zz_islocked(-1) || !_zz_iswatched(oldfd) 209 || !_zz_isactive(oldfd)) 210 return ret; 211 212 if(ret >= 0) 213 { 214 /* We must close newfd if it was open, but only if oldfd != newfd 215 * and if dup2() suceeded. */ 216 if(oldfd != newfd && _zz_iswatched(newfd) && _zz_isactive(newfd)) 217 _zz_unregister(newfd); 218 219 debug("%s(%i, %i) = %i", __func__, oldfd, newfd, ret); 220 _zz_register(ret); 221 } 222 223 return ret; 224 } 225 #endif 226 174 227 #if defined HAVE_ACCEPT 175 228 int NEW(accept)(int sockfd, struct sockaddr *addr, SOCKLEN_T *addrlen)
Note: See TracChangeset
for help on using the changeset viewer.