Changeset: 185e0ec7c40a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=185e0ec7c40a
Modified Files:
monetdb5/mal/mal_client.c
monetdb5/mal/mal_client.h
monetdb5/mal/mal_session.c
Branch: Feb2013
Log Message:
properly close the streams after login failures
diffs (144 lines):
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -175,7 +175,7 @@ MCgetClient(int id)
return mal_clients + id;
}
-static void
+void
MCexitClient(Client c)
{
#ifdef MAL_CLIENT_DEBUG
diff --git a/monetdb5/mal/mal_client.h b/monetdb5/mal/mal_client.h
--- a/monetdb5/mal/mal_client.h
+++ b/monetdb5/mal/mal_client.h
@@ -198,6 +198,7 @@ mal_export int MCdefault;
mal_export Client MCgetClient(int id);
mal_export Client MCinitClient(oid user, bstream *fin, stream *fout);
mal_export Client MCinitClientRecord(Client c, oid user, bstream *fin, stream
*fout);
+mal_export void MCexitClient(Client c);
mal_export int MCinitClientThread(Client c);
mal_export void MCcloseClient(Client c);
mal_export Client MCforkClient(Client c);
diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c
--- a/monetdb5/mal/mal_session.c
+++ b/monetdb5/mal/mal_session.c
@@ -136,6 +136,18 @@ MSinitClientPrg(Client cntxt, str mod, s
* The scheduleClient receives a challenge response consisting of
* endian:user:password:lang:database:
*/
+static void
+exit_streams( bstream *fin, stream *fout )
+{
+ if (fout && fout != GDKstdout) {
+ mnstr_flush(fout);
+ (void) mnstr_close(fout);
+ (void) mnstr_destroy(fout);
+ }
+ if (fin)
+ (void) bstream_destroy(fin);
+}
+
void
MSscheduleClient(str command, str challenge, bstream *fin, stream *fout)
{
@@ -154,7 +166,7 @@ MSscheduleClient(str command, str challe
user = s + 1;
} else {
mnstr_printf(fout, "!incomplete challenge '%s'\n", user);
- mnstr_flush(fout);
+ exit_streams(fin, fout);
GDKfree(command);
return;
}
@@ -167,7 +179,7 @@ MSscheduleClient(str command, str challe
/* decode algorithm, i.e. {plain}mypasswordchallenge */
if (*passwd != '{') {
mnstr_printf(fout, "!invalid password entry\n");
- mnstr_flush(fout);
+ exit_streams(fin, fout);
GDKfree(command);
return;
}
@@ -175,7 +187,7 @@ MSscheduleClient(str command, str challe
s = strchr(algo, '}');
if (!s) {
mnstr_printf(fout, "!invalid password entry\n");
- mnstr_flush(fout);
+ exit_streams(fin, fout);
GDKfree(command);
return;
}
@@ -183,7 +195,7 @@ MSscheduleClient(str command, str challe
passwd = s + 1;
} else {
mnstr_printf(fout, "!incomplete challenge '%s'\n", user);
- mnstr_flush(fout);
+ exit_streams(fin, fout);
GDKfree(command);
return;
}
@@ -195,7 +207,7 @@ MSscheduleClient(str command, str challe
lang = s + 1;
} else {
mnstr_printf(fout, "!incomplete challenge, missing language\n");
- mnstr_flush(fout);
+ exit_streams(fin, fout);
GDKfree(command);
return;
}
@@ -220,7 +232,7 @@ MSscheduleClient(str command, str challe
"did you mean to connect to
monetdbd instead?\n",
database, dbname);
/* flush the error to the client, and abort further execution */
- mnstr_flush(fout);
+ exit_streams(fin, fout);
GDKfree(command);
return;
} else {
@@ -235,7 +247,7 @@ MSscheduleClient(str command, str challe
err = AUTHcheckCredentials(&uid, &root, &user, &passwd,
&challenge, &algo);
if (err != MAL_SUCCEED) {
mnstr_printf(fout, "!%s\n", err);
- mnstr_flush(fout);
+ exit_streams(fin, fout);
GDKfree(command);
return;
}
@@ -249,7 +261,7 @@ MSscheduleClient(str command, str challe
GDKfree(err);
mnstr_printf(fout, "!internal server error, "
"please try again later\n");
- mnstr_flush(fout);
+ exit_streams(fin, fout);
GDKfree(command);
return;
}
@@ -260,7 +272,7 @@ MSscheduleClient(str command, str challe
} else {
mnstr_printf(fout, "!server is running in "
"maintenance mode,
please try again later\n");
- mnstr_flush(fout);
+ exit_streams(fin, fout);
SABAOTHfreeStatus(&stats);
GDKfree(command);
return;
@@ -272,7 +284,7 @@ MSscheduleClient(str command, str challe
if (c == NULL) {
mnstr_printf(fout, "!maximum concurrent client limit
reached "
"(%d), please try
again later\n", MAL_MAXCLIENTS);
- mnstr_flush(fout);
+ exit_streams(fin, fout);
GDKfree(command);
return;
}
@@ -311,6 +323,8 @@ MSscheduleClient(str command, str challe
mnstr_printf(fout, "!internal server error (cannot fork new "
"client thread), please try
again later\n");
mnstr_flush(fout);
+ c->mode = FINISHING;
+ MCexitClient(c);
showException(c->fdout, MAL, "initClient", "cannot fork new
client thread");
return;
}
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list