Commit 8d72ef6e authored by Andrew Tridgell's avatar Andrew Tridgell

use error to detect lockfile open failures vs. max connections reached

and report an appropriate error message
parent bcf5b133
...@@ -132,9 +132,16 @@ static int rsync_module(int fd, int i) ...@@ -132,9 +132,16 @@ static int rsync_module(int fd, int i)
} }
if (!claim_connection(lp_lock_file(), lp_max_connections())) { if (!claim_connection(lp_lock_file(), lp_max_connections())) {
if (errno) {
rprintf(FERROR,"failed to open lock file %s : %s\n",
lp_lock_file(), strerror(errno));
io_printf(fd,"@ERROR: failed to open lock file %s : %s\n",
lp_lock_file(), strerror(errno));
} else {
rprintf(FERROR,"max connections (%d) reached\n", rprintf(FERROR,"max connections (%d) reached\n",
lp_max_connections()); lp_max_connections());
io_printf(fd,"@ERROR: max connections (%d) reached - try again later\n", lp_max_connections()); io_printf(fd,"@ERROR: max connections (%d) reached - try again later\n", lp_max_connections());
}
return -1; return -1;
} }
......
...@@ -41,6 +41,9 @@ int claim_connection(char *fname,int max_connections) ...@@ -41,6 +41,9 @@ int claim_connection(char *fname,int max_connections)
if (lock_range(fd, i*4, 4)) return 1; if (lock_range(fd, i*4, 4)) return 1;
} }
/* only interested in open failures */
errno = 0;
close(fd); close(fd);
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment