lib/libdsa/dsalib_updown.c | 47 ++++++++++++++++-----------------------------
1 file changed, 17 insertions(+), 30 deletions(-)
New commits:
commit cc422c4d21ec4ae262601fe2b294b49bb4ea5d97
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Fri Apr 29 10:23:40 2011 -0700
Bug 700875 - (cov#10778) Cleanup ds_bring_up_server_install() in dsalib
The ds_bring_up_server_install() function looks to have some cut/paste errors
in it that throw off the intended logic.
If XP_WIN32 is not defined, the else at line 256 is a part of the if at line
246. If XP_WIN32 is defined, the else at line 256 is a part of the if at line
227, which seems wrong.
It also seems like the if statement at line 227 should be closed out after line
237. The intent looks to be that we want to print the contents of statfile is
the verbose option is set. The code beginning at line 239 seems unrelated to
the verbose option, as it's setting the status that gets returned.
This could be some sort of copy/paste area wince the if/else block beginning at
line 207 seems the same as the if/else block starting at line 239.
diff --git a/lib/libdsa/dsalib_updown.c b/lib/libdsa/dsalib_updown.c
index 5ea331e..c3b460c 100644
--- a/lib/libdsa/dsalib_updown.c
+++ b/lib/libdsa/dsalib_updown.c
@@ -223,9 +223,24 @@ ds_bring_up_server_install(int verbose, char *instdir, char
*errorlog)
if (verbose)
ds_send_error("error in starting server.", 1);
return(retval);
+ } else {
+ int tries;
+ for (tries = 0; tries < secondsToWaitForServer; tries++) {
+ if (ds_get_updown_status() == DS_SERVER_UP) {
+ status = DS_SERVER_UP;
+ break;
+ }
+ PR_Sleep(PR_SecondsToInterval(1));
+ }
+ if (verbose) {
+ char str[100];
+ PR_snprintf(str, sizeof(str), "Had to retry %d times", tries);
+ ds_send_status(str);
+ }
}
- if (verbose) {
+
#if !defined( XP_WIN32 )
+ if (verbose) {
if( !(sf = fopen(statfile, "r")) ) {
ds_send_error("could not read status file.", 1);
return(DS_SERVER_UNKNOWN);
@@ -235,36 +250,8 @@ ds_bring_up_server_install(int verbose, char *instdir, char
*errorlog)
ds_send_error(startup_line, 0);
fclose(sf);
unlink(statfile);
-#endif
- status = DS_SERVER_UNKNOWN;
- if (strstr(msgBuf, "semget"))
- status = DS_SERVER_MAX_SEMAPHORES;
- else if (strstr(msgBuf, "Back-End Initialization Failed"))
- status = DS_SERVER_CORRUPTED_DB;
- else if (strstr(msgBuf, "not initialized... exiting"))
- status = DS_SERVER_CORRUPTED_DB;
- else if (strstr(msgBuf, "address is in use"))
- status = DS_SERVER_PORT_IN_USE;
-#if defined( XP_WIN32 )
- /* on NT, if we run out of resources, there will not even be an error
- log
- */
- else if (msgBuf[0] == 0) {
- status = DS_SERVER_NO_RESOURCES;
- }
-#endif
- } else {
- int tries;
- for (tries = 0; tries < secondsToWaitForServer; tries++) {
- if (ds_get_updown_status() == DS_SERVER_UP) break;
- PR_Sleep(PR_SecondsToInterval(1));
- }
- if (verbose) {
- char str[100];
- PR_snprintf(str, sizeof(str), "Had to retry %d times", tries);
- ds_send_status(str);
- }
}
+#endif
if ( (status == DS_SERVER_DOWN) || (status == DS_SERVER_UNKNOWN) )
status = ds_get_updown_status();