Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

connection.c File Reference

Go to the source code of this file.

Functions

int claim_connection (char *fname, int max_connections)


Function Documentation

int claim_connection char *    fname,
int    max_connections
 

Definition at line 26 of file connection.c.

References lock_range().

Referenced by 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 }


Generated on Tue Apr 16 12:37:38 2002 for rsync by doxygen1.2.15