関数 | |
int | claim_connection (char *fname, int max_connections) |
int claim_connection | ( | char * | fname, | |
int | max_connections | |||
) |
connection.c の 26 行で定義されています。
参照先 errno・lock_range().
参照元 rsync_module().
00027 { 00028 int fd, i; 00029 00030 if (max_connections <= 0) 00031 return 1; 00032 00033 fd = open(fname,O_RDWR|O_CREAT, 0600); 00034 00035 if (fd == -1) { 00036 return 0; 00037 } 00038 00039 /* find a free spot */ 00040 for (i=0;i<max_connections;i++) { 00041 if (lock_range(fd, i*4, 4)) return 1; 00042 } 00043 00044 /* only interested in open failures */ 00045 errno = 0; 00046 00047 close(fd); 00048 return 0; 00049 }