|
|
sybperl-l Archive
Up Prev Next
From: "Avis, Ed" <avised at kbcfp dot com>
Subject: RE: Feature request: set maximum number of connections
Date: Jan 30 2004 2:48PM
diff -ru DBD-Sybase-1.02.3/Sybase.pm DBD-Sybase-1.02.3-new/Sybase.pm
--- DBD-Sybase-1.02.3/Sybase.pm 2004-01-21 15:46:58.000000000 +0000
+++ DBD-Sybase-1.02.3-new/Sybase.pm 2004-01-30 14:19:40.000000000 +0000
@@ -754,6 +754,13 @@
environment variable if no server is specified in the connect()) and is
expected to return a string (the Kerberos serverprincipal) to the caller.
+=item maxConnect
+
+Sets the maximum number of connections that can be opened. It is an
+error to try setting this lower than the number currently open;
+apart from that, you can increase or decrease it as you want. It sets
+the C property in ctlib.
+
=back
These different parameters (as well as the server name) can be strung
diff -ru DBD-Sybase-1.02.3/dbdimp.c DBD-Sybase-1.02.3-new/dbdimp.c
--- DBD-Sybase-1.02.3/dbdimp.c 2004-01-21 15:46:58.000000000 +0000
+++ DBD-Sybase-1.02.3-new/dbdimp.c 2004-01-30 14:42:04.000000000 +0000
@@ -645,13 +645,6 @@
CS_UNUSED, NULL)) != CS_SUCCEED)
croak("DBD::Sybase initialize: ct_config(netio) failed");
-#if defined(MAX_CONNECT)
- netio_type = MAX_CONNECT;
- if((retcode = ct_config(context, CS_SET, CS_MAX_CONNECT, &netio_type,
- CS_UNUSED, NULL)) != CS_SUCCEED)
- croak("DBD::Sybase initialize: ct_config(max_connect) failed");
-#endif
-
{
char out[1024], *p;
retcode = ct_config(context, CS_GET, CS_VER_STRING,
@@ -805,6 +798,7 @@
imp_dbh->database[0] = 0;
imp_dbh->curr_db[0] = 0;
imp_dbh->encryptPassword[0] = 0;
+ imp_dbh->maxConnect[0] = 0;
imp_dbh->showSql = 0;
imp_dbh->showEed = 0;
imp_dbh->flushFinish = 0;
@@ -840,6 +834,7 @@
extractFromDsn("tdsLevel=", dsn, imp_dbh->tdsLevel, 30);
extractFromDsn("encryptPassword=", dsn, imp_dbh->encryptPassword, 10);
extractFromDsn("kerberos=", dsn, imp_dbh->kerberosPrincipal, 32);
+ extractFromDsn("maxConnect=", dsn, imp_dbh->maxConnect, 10);
} else {
strncpy(imp_dbh->server, dsn, 64);
imp_dbh->server[63] = 0;
@@ -1094,6 +1089,35 @@
return 0;
}
}
+ if (*imp_dbh->maxConnect)
+ {
+ /* Maximum number of connections. */
+ const char *const s = imp_dbh->maxConnect;
+ const char *p = s;
+ int i;
+
+ /* atoi() does little error checking, so validate first. We
+ do know that the string length is short enough to be within
+ the range for integers. */
+ if (*p == '+') ++p;
+ while (isdigit(*p)) ++p;
+ if (*p)
+ {
+ warn("maxConnect must be a positive integer, not '%s'", s);
+ return 0;
+ }
+
+ i = atoi(s);
+ if (i < 1)
+ {
+ warn("maxConnect must be positive, not '%s'", s);
+ return 0;
+ }
+
+ if((retcode = ct_config(context, CS_SET, CS_MAX_CONNECT, &i,
+ CS_UNUSED, NULL)) != CS_SUCCEED)
+ croak("ct_config(max_connect) failed");
+ }
if(retcode == CS_SUCCEED)
{
if(imp_dbh->encryptPassword[0] != 0) {
diff -ru DBD-Sybase-1.02.3/dbdimp.h DBD-Sybase-1.02.3-new/dbdimp.h
--- DBD-Sybase-1.02.3/dbdimp.h 2004-01-07 23:38:42.000000000 +0000
+++ DBD-Sybase-1.02.3-new/dbdimp.h 2004-01-30 13:58:38.000000000 +0000
@@ -77,6 +77,7 @@
char tdsLevel[30];
char encryptPassword[10];
char kerberosPrincipal[32];
+ char maxConnect[10];
char serverVersion[15];
|