connection.c

説明を見る。
00001 /* 
00002    Copyright (C) Andrew Tridgell 1998
00003    
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 2 of the License, or
00007    (at your option) any later version.
00008    
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012    GNU General Public License for more details.
00013    
00014    You should have received a copy of the GNU General Public License
00015    along with this program; if not, write to the Free Software
00016    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 /* support the max connections option */
00020 #include "rsync.h"
00021 
00022 
00023 /****************************************************************************
00024 simple routine to do connection counting
00025 ****************************************************************************/
00026 int claim_connection(char *fname,int max_connections)
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 }

rsyncに対してSat Dec 5 19:45:41 2009に生成されました。  doxygen 1.4.7