2003-05-26 09:18:31 +00:00
|
|
|
/* NeoStats - IRC Statistical Services
|
2004-01-14 11:36:37 +00:00
|
|
|
** Copyright (c) 1999-2004 Adam Rutter, Justin Hammond
|
2002-09-04 08:40:29 +00:00
|
|
|
** http://www.neostats.net/
|
|
|
|
**
|
|
|
|
** Portions Copyright (c) 2000-2001 ^Enigma^
|
|
|
|
**
|
|
|
|
** Portions Copyright (c) 1999 Johnathan George net@lite.net
|
|
|
|
**
|
|
|
|
** This program is free software; you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation; either version 2 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** This program is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with this program; if not, write to the Free Software
|
|
|
|
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
** USA
|
|
|
|
**
|
|
|
|
** NeoStats CVS Identification
|
2003-09-22 15:04:15 +00:00
|
|
|
** $Id$
|
2000-02-03 23:45:51 +00:00
|
|
|
*/
|
|
|
|
|
2002-08-28 09:11:47 +00:00
|
|
|
#include <fcntl.h>
|
2003-11-03 13:57:11 +00:00
|
|
|
#include <sys/poll.h>
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
2000-02-03 23:45:51 +00:00
|
|
|
#include "stats.h"
|
2000-03-02 01:31:24 +00:00
|
|
|
#include "dl.h"
|
2004-01-29 22:16:09 +00:00
|
|
|
#include "adns.h"
|
2003-04-10 09:32:01 +00:00
|
|
|
#include "conf.h"
|
2003-04-11 09:26:31 +00:00
|
|
|
#include "log.h"
|
2003-11-18 11:51:09 +00:00
|
|
|
#include "timer.h"
|
|
|
|
#include "dns.h"
|
2003-12-03 15:32:14 +00:00
|
|
|
#include "transfer.h"
|
|
|
|
#include "curl.h"
|
2004-01-27 13:32:54 +00:00
|
|
|
#include "ircstring.h"
|
2004-02-02 21:01:33 +00:00
|
|
|
#include "dotconf.h"
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
#ifdef SQLSRV
|
|
|
|
#include "sqlsrv/rta.h"
|
|
|
|
#endif
|
2000-02-03 23:45:51 +00:00
|
|
|
|
2003-10-09 18:55:32 +00:00
|
|
|
static void recvlog (char *line);
|
|
|
|
|
|
|
|
static struct sockaddr_in lsa;
|
|
|
|
static int dobind;
|
|
|
|
|
2003-11-18 11:51:09 +00:00
|
|
|
int servsock;
|
|
|
|
char recbuf[BUFSIZE];
|
|
|
|
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
|
|
|
|
#ifdef SQLSRV
|
|
|
|
|
|
|
|
#define MAXSQLCON 5
|
|
|
|
|
|
|
|
/* sqlsrv struct for tracking connections */
|
|
|
|
typedef struct Sql_Conn {
|
|
|
|
struct sockaddr_in cliskt;
|
|
|
|
int fd;
|
|
|
|
long long nbytein;
|
|
|
|
long long nbyteout;
|
|
|
|
char response[50000];
|
|
|
|
int responsefree;
|
|
|
|
int cmdpos;
|
|
|
|
int cmd[1000];
|
|
|
|
} Sql_Conn;
|
|
|
|
|
2003-12-28 07:23:42 +00:00
|
|
|
int sqlListenSock = -1;
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
|
|
|
|
list_t *sqlconnections;
|
|
|
|
|
|
|
|
|
|
|
|
static void sql_accept_conn(int srvfd);
|
|
|
|
static int sqllisten_on_port(int port);
|
|
|
|
static int sql_handle_ui_request(lnode_t *sqlnode);
|
|
|
|
static int sql_handle_ui_output(lnode_t *sqlnode);
|
2003-12-28 07:23:42 +00:00
|
|
|
int check_sql_sock();
|
|
|
|
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-10-09 18:55:32 +00:00
|
|
|
/** @brief Connect to a server
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
*
|
|
|
|
* also setups the SQL listen socket if defined
|
2003-10-09 18:55:32 +00:00
|
|
|
*
|
|
|
|
* @param host to connect to
|
|
|
|
* @param port on remote host to connect to
|
|
|
|
*
|
2003-11-03 13:57:11 +00:00
|
|
|
* @return socket connected to on success
|
|
|
|
* NS_FAILURE on failure
|
2003-10-09 18:55:32 +00:00
|
|
|
*/
|
2003-07-30 13:58:22 +00:00
|
|
|
int
|
|
|
|
ConnectTo (char *host, int port)
|
2000-02-03 23:45:51 +00:00
|
|
|
{
|
2003-11-18 11:51:09 +00:00
|
|
|
int ret;
|
2000-02-03 23:45:51 +00:00
|
|
|
struct hostent *hp;
|
|
|
|
struct sockaddr_in sa;
|
|
|
|
int s;
|
|
|
|
|
2003-04-10 06:06:10 +00:00
|
|
|
dobind = 0;
|
|
|
|
/* bind to a local ip */
|
2003-07-30 13:58:22 +00:00
|
|
|
memset (&lsa, 0, sizeof (lsa));
|
2003-11-03 13:57:11 +00:00
|
|
|
if (me.local[0] != 0) {
|
2003-07-30 13:58:22 +00:00
|
|
|
if ((hp = gethostbyname (me.local)) == NULL) {
|
|
|
|
nlog (LOG_WARNING, LOG_CORE, "Warning, Couldn't bind to IP address %s", me.local);
|
2003-04-10 06:06:10 +00:00
|
|
|
} else {
|
2003-07-30 13:58:22 +00:00
|
|
|
memcpy ((char *) &lsa.sin_addr, hp->h_addr, hp->h_length);
|
2003-04-10 06:06:10 +00:00
|
|
|
lsa.sin_family = hp->h_addrtype;
|
|
|
|
dobind = 1;
|
|
|
|
}
|
|
|
|
}
|
2003-07-30 13:58:22 +00:00
|
|
|
if ((hp = gethostbyname (host)) == NULL) {
|
2003-11-03 13:57:11 +00:00
|
|
|
return NS_FAILURE;
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
|
|
|
|
2003-11-18 11:51:09 +00:00
|
|
|
if ((s = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
|
2004-01-31 06:26:56 +00:00
|
|
|
free(hp);
|
2003-11-03 13:57:11 +00:00
|
|
|
return NS_FAILURE;
|
2003-11-18 11:51:09 +00:00
|
|
|
}
|
2003-04-10 06:06:10 +00:00
|
|
|
if (dobind > 0) {
|
2003-07-30 13:58:22 +00:00
|
|
|
if (bind (s, (struct sockaddr *) &lsa, sizeof (lsa)) < 0) {
|
|
|
|
nlog (LOG_WARNING, LOG_CORE, "bind(): Warning, Couldn't bind to IP address %s", strerror (errno));
|
2003-04-10 06:06:10 +00:00
|
|
|
}
|
|
|
|
}
|
2003-06-13 13:11:50 +00:00
|
|
|
|
2003-07-30 13:58:22 +00:00
|
|
|
bzero (&sa, sizeof (sa));
|
2000-02-03 23:45:51 +00:00
|
|
|
sa.sin_family = AF_INET;
|
2003-07-30 13:58:22 +00:00
|
|
|
sa.sin_port = htons (port);
|
|
|
|
bcopy (hp->h_addr, (char *) &sa.sin_addr, hp->h_length);
|
2000-02-03 23:45:51 +00:00
|
|
|
|
2003-11-18 11:51:09 +00:00
|
|
|
ret=connect (s, (struct sockaddr *) &sa, sizeof (sa));
|
|
|
|
if (ret< 0) {
|
2003-07-30 13:58:22 +00:00
|
|
|
close (s);
|
2003-11-03 13:57:11 +00:00
|
|
|
return NS_FAILURE;
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
#ifdef SQLSRV
|
|
|
|
/* init the sql Listen Socket now as well */
|
|
|
|
sqlconnections = list_create(MAXSQLCON);
|
|
|
|
|
|
|
|
sqlListenSock = sqllisten_on_port(me.sqlport);
|
|
|
|
if (sqlListenSock == -1) {
|
|
|
|
nlog(LOG_CRITICAL, LOG_CORE, "Failed to Setup Sql Port. SQL not available");
|
|
|
|
}
|
|
|
|
#endif
|
2000-02-03 23:45:51 +00:00
|
|
|
return s;
|
|
|
|
}
|
2003-06-13 13:11:50 +00:00
|
|
|
|
2003-10-09 18:55:32 +00:00
|
|
|
/** @brief main recv loop
|
|
|
|
*
|
|
|
|
* @param none
|
|
|
|
*
|
|
|
|
* @return none
|
|
|
|
*/
|
2003-07-30 13:58:22 +00:00
|
|
|
void
|
|
|
|
read_loop ()
|
2000-02-03 23:45:51 +00:00
|
|
|
{
|
|
|
|
register int i, j, SelectResult;
|
2002-07-30 04:26:28 +00:00
|
|
|
struct timeval *TimeOut, tvbuf;
|
|
|
|
fd_set readfds, writefds, errfds;
|
2003-12-03 15:32:14 +00:00
|
|
|
int maxfdsunused;
|
2000-02-03 23:45:51 +00:00
|
|
|
char c;
|
|
|
|
char buf[BUFSIZE];
|
2003-11-18 11:51:09 +00:00
|
|
|
ModSock *mod_sock;
|
2003-11-03 13:57:11 +00:00
|
|
|
struct pollfd *ufds;
|
|
|
|
int pollsize, pollflag;
|
2002-02-28 07:54:13 +00:00
|
|
|
hscan_t ss;
|
|
|
|
hnode_t *sn;
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
#ifdef SQLSRV
|
|
|
|
lnode_t *sqlnode;
|
|
|
|
Sql_Conn *sqldata;
|
|
|
|
#endif
|
2000-02-03 23:45:51 +00:00
|
|
|
|
2004-01-31 06:26:56 +00:00
|
|
|
/* XXX Valgrind reports these two as lost memory, Should clean up before we exit */
|
2003-07-30 13:58:22 +00:00
|
|
|
TimeOut = malloc (sizeof (struct timeval));
|
2003-11-18 11:51:09 +00:00
|
|
|
ufds = malloc((sizeof *ufds) * me.maxsocks);
|
2002-07-30 05:16:07 +00:00
|
|
|
|
2004-01-12 00:25:37 +00:00
|
|
|
me.lastmsg = me.now;
|
2000-02-03 23:45:51 +00:00
|
|
|
while (1) {
|
2003-09-18 12:21:32 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-07-30 13:58:22 +00:00
|
|
|
memset (buf, '\0', BUFSIZE);
|
2003-11-03 13:57:11 +00:00
|
|
|
me.now = time(NULL);
|
2004-02-04 18:47:24 +00:00
|
|
|
ircsnprintf (me.strnow, STR_TIME_T_SIZE, "%ld", (long)me.now);
|
2003-10-14 15:29:41 +00:00
|
|
|
CheckTimers ();
|
2003-09-18 12:21:32 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-11-03 13:57:11 +00:00
|
|
|
me.now = time(NULL);
|
2004-02-04 18:47:24 +00:00
|
|
|
ircsnprintf (me.strnow, STR_TIME_T_SIZE, "%ld", (long)me.now);
|
2003-07-30 13:58:22 +00:00
|
|
|
FD_ZERO (&readfds);
|
|
|
|
FD_ZERO (&writefds);
|
|
|
|
FD_ZERO (&errfds);
|
2003-11-18 11:51:09 +00:00
|
|
|
// memset(ufds, 0, (sizeof *ufds) * me.maxsocks);
|
2003-11-03 13:57:11 +00:00
|
|
|
pollsize = 0;
|
2003-07-30 13:58:22 +00:00
|
|
|
FD_SET (servsock, &readfds);
|
|
|
|
hash_scan_begin (&ss, sockh);
|
2003-06-13 13:11:50 +00:00
|
|
|
me.cursocks = 1; /* always one socket for ircd */
|
2003-07-30 13:58:22 +00:00
|
|
|
while ((sn = hash_scan_next (&ss)) != NULL) {
|
|
|
|
mod_sock = hnode_get (sn);
|
2003-11-03 13:57:11 +00:00
|
|
|
if (mod_sock->socktype == SOCK_STANDARD) {
|
|
|
|
if (mod_sock->readfnc)
|
|
|
|
FD_SET (mod_sock->sock_no, &readfds);
|
|
|
|
if (mod_sock->writefnc)
|
|
|
|
FD_SET (mod_sock->sock_no, &writefds);
|
|
|
|
if (mod_sock->errfnc)
|
|
|
|
FD_SET (mod_sock->sock_no, &errfds);
|
|
|
|
++me.cursocks;
|
|
|
|
} else {
|
|
|
|
/* its a poll interface, setup for select instead */
|
2003-11-05 15:00:12 +00:00
|
|
|
SET_SEGV_INMODULE(mod_sock->modname);
|
2003-11-03 13:57:11 +00:00
|
|
|
j = mod_sock->beforepoll (mod_sock->data, ufds);
|
2003-11-05 15:00:12 +00:00
|
|
|
CLEAR_SEGV_INMODULE();
|
2003-12-08 14:58:36 +00:00
|
|
|
/* if we don't have any socks, just continue */
|
|
|
|
if (j == -1)
|
|
|
|
continue;
|
|
|
|
|
2003-11-03 13:57:11 +00:00
|
|
|
if (j > pollsize) pollsize = j;
|
|
|
|
/* run through the ufds set and translate to select FDSET's */
|
|
|
|
for (i = 0; i < j; i++) {
|
|
|
|
if (ufds[i].events & POLLIN) {
|
|
|
|
FD_SET (ufds[i].fd, &readfds);
|
|
|
|
}
|
|
|
|
if (ufds[i].events & POLLOUT) {
|
|
|
|
FD_SET (ufds[i].fd, &writefds);
|
|
|
|
}
|
|
|
|
if (ufds[i].events & POLLERR) {
|
|
|
|
FD_SET (ufds[i].fd, &errfds);
|
|
|
|
}
|
|
|
|
++me.cursocks;
|
|
|
|
}
|
|
|
|
}
|
2000-03-02 01:31:24 +00:00
|
|
|
}
|
2002-07-30 04:26:28 +00:00
|
|
|
/* adns stuff... whats its interested in */
|
2003-07-30 13:58:22 +00:00
|
|
|
adns_beforeselect (ads, &me.maxsocks, &readfds, &writefds, &errfds, &TimeOut, &tvbuf, 0);
|
2003-03-31 08:50:43 +00:00
|
|
|
/* adns may change this, but we tell it to go away!!! */
|
|
|
|
TimeOut->tv_sec = 1;
|
|
|
|
TimeOut->tv_usec = 0;
|
2003-12-03 15:32:14 +00:00
|
|
|
|
|
|
|
/* add the fds for the curl library as well */
|
|
|
|
/* XXX Should this be a pollsize or maxfdsunused... not sure yet */
|
2003-12-08 14:58:36 +00:00
|
|
|
curl_multi_fdset(curlmultihandle, &readfds, &writefds, &errfds, &maxfdsunused);
|
2003-12-03 15:32:14 +00:00
|
|
|
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
#ifdef SQLSRV
|
|
|
|
/* if we have sql support, add the Listen Socket to the fds */
|
|
|
|
if (sqlListenSock > 0)
|
|
|
|
FD_SET(sqlListenSock, &readfds);
|
|
|
|
|
|
|
|
/* if we have any existing connections, add them of course */
|
|
|
|
if (list_count(sqlconnections) > 0) {
|
|
|
|
sqlnode = list_first(sqlconnections);
|
|
|
|
while (sqlnode != NULL) {
|
|
|
|
sqldata = lnode_get(sqlnode);
|
|
|
|
if (sqldata->responsefree < 50000) {
|
|
|
|
FD_SET(sqldata->fd, &writefds);
|
|
|
|
} else {
|
|
|
|
FD_SET(sqldata->fd, &readfds);
|
|
|
|
}
|
|
|
|
sqlnode = list_next(sqlconnections, sqlnode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2003-07-30 13:58:22 +00:00
|
|
|
SelectResult = select (FD_SETSIZE, &readfds, &writefds, &errfds, TimeOut);
|
2003-11-03 13:57:11 +00:00
|
|
|
me.now = time(NULL);
|
2004-02-04 18:47:24 +00:00
|
|
|
ircsnprintf (me.strnow, STR_TIME_T_SIZE, "%ld", (long)me.now);
|
2000-02-03 23:45:51 +00:00
|
|
|
if (SelectResult > 0) {
|
2003-12-03 15:32:14 +00:00
|
|
|
/* check ADNS fds */
|
2003-07-30 13:58:22 +00:00
|
|
|
adns_afterselect (ads, me.maxsocks, &readfds, &writefds, &errfds, 0);
|
2003-06-13 13:11:50 +00:00
|
|
|
|
2003-11-03 13:57:11 +00:00
|
|
|
/* do any dns related callbacks now */
|
2003-07-30 13:58:22 +00:00
|
|
|
do_dns ();
|
2003-11-03 13:57:11 +00:00
|
|
|
|
2003-12-03 15:32:14 +00:00
|
|
|
/* check CURL fds */
|
2003-12-08 13:09:39 +00:00
|
|
|
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(curlmultihandle, &maxfdsunused)) {
|
2003-12-05 15:07:41 +00:00
|
|
|
}
|
2003-12-08 13:09:39 +00:00
|
|
|
transfer_status();
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
#ifdef SQLSRV
|
|
|
|
/* did we get a connection to the SQL listen sock */
|
|
|
|
if ((sqlListenSock > 0) && (FD_ISSET(sqlListenSock, &readfds)))
|
|
|
|
sql_accept_conn(sqlListenSock);
|
|
|
|
restartsql:
|
|
|
|
/* don't bother checking the sql connections if we dont have any active connections! */
|
|
|
|
if (list_count(sqlconnections) > 0) {
|
|
|
|
sqlnode = list_first(sqlconnections);
|
|
|
|
while (sqlnode != NULL) {
|
|
|
|
sqldata = lnode_get(sqlnode);
|
|
|
|
if (FD_ISSET(sqldata->fd, &readfds)) {
|
|
|
|
if (sql_handle_ui_request(sqlnode) == NS_FAILURE) {
|
|
|
|
goto restartsql;
|
|
|
|
}
|
|
|
|
} else if (FD_ISSET(sqldata->fd, &writefds)) {
|
|
|
|
if (sql_handle_ui_output(sqlnode) == NS_FAILURE) {
|
|
|
|
goto restartsql;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sqlnode = list_next(sqlconnections, sqlnode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2003-10-29 13:32:37 +00:00
|
|
|
if (FD_ISSET (servsock, &readfds)) {
|
|
|
|
for (j = 0; j < BUFSIZE; j++) {
|
2003-07-30 13:58:22 +00:00
|
|
|
i = read (servsock, &c, 1);
|
2000-03-03 06:03:42 +00:00
|
|
|
me.RcveBytes++;
|
2000-02-03 23:45:51 +00:00
|
|
|
if (i >= 0) {
|
|
|
|
buf[j] = c;
|
2003-10-29 13:58:07 +00:00
|
|
|
if ((c == '\n') || (c == '\r')) {
|
2000-03-03 06:03:42 +00:00
|
|
|
me.RcveM++;
|
2003-11-03 13:57:11 +00:00
|
|
|
me.lastmsg = me.now;
|
2003-06-13 13:11:50 +00:00
|
|
|
if (config.recvlog)
|
2003-07-30 13:58:22 +00:00
|
|
|
recvlog (buf);
|
|
|
|
parse (buf);
|
2000-02-03 23:45:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2003-10-07 14:26:21 +00:00
|
|
|
nlog (LOG_WARNING, LOG_CORE, "read returned an Error");
|
2003-11-21 10:42:50 +00:00
|
|
|
servsock = -1;
|
2000-02-03 23:45:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-10-29 13:32:37 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* this checks if there is any data waiting on a socket for a module */
|
|
|
|
hash_scan_begin (&ss, sockh);
|
|
|
|
while ((sn = hash_scan_next (&ss)) != NULL) {
|
2003-12-08 14:58:36 +00:00
|
|
|
pollflag = 0;
|
2003-10-29 13:32:37 +00:00
|
|
|
mod_sock = hnode_get (sn);
|
|
|
|
SET_SEGV_INMODULE(mod_sock->modname);
|
2003-11-03 13:57:11 +00:00
|
|
|
if (mod_sock->socktype == SOCK_STANDARD) {
|
|
|
|
if (FD_ISSET (mod_sock->sock_no, &readfds)) {
|
|
|
|
nlog (LOG_DEBUG3, LOG_CORE, "Running module %s readsock function for %s", mod_sock->modname, mod_sock->sockname);
|
|
|
|
if (mod_sock->readfnc (mod_sock->sock_no, mod_sock->sockname) < 0)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (FD_ISSET (mod_sock->sock_no, &writefds)) {
|
|
|
|
nlog (LOG_DEBUG3, LOG_CORE, "Running module %s writesock function for %s", mod_sock->modname, mod_sock->sockname);
|
|
|
|
if (mod_sock->writefnc (mod_sock->sock_no, mod_sock->sockname) < 0)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (FD_ISSET (mod_sock->sock_no, &errfds)) {
|
|
|
|
nlog (LOG_DEBUG3, LOG_CORE, "Running module %s errorsock function for %s", mod_sock->modname, mod_sock->sockname);
|
|
|
|
if (mod_sock->errfnc (mod_sock->sock_no, mod_sock->sockname) < 0)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (pollflag != 1) {
|
|
|
|
for (i = 0; i < pollsize; i++) {
|
|
|
|
if (FD_ISSET(ufds[i].fd, &readfds)) {
|
|
|
|
ufds[i].revents |= POLLIN;
|
|
|
|
pollflag = 1;
|
|
|
|
}
|
|
|
|
if (FD_ISSET(ufds[i].fd, &writefds)) {
|
|
|
|
ufds[i].revents |= POLLOUT;
|
|
|
|
pollflag = 1;
|
|
|
|
}
|
|
|
|
if (FD_ISSET(ufds[i].fd, &errfds)) {
|
|
|
|
ufds[i].revents |= POLLERR;
|
|
|
|
pollflag = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pollflag == 1) {
|
|
|
|
mod_sock->afterpoll(mod_sock->data, ufds, pollsize);
|
|
|
|
}
|
2000-03-02 01:31:24 +00:00
|
|
|
}
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
2003-10-29 13:32:37 +00:00
|
|
|
CLEAR_SEGV_INMODULE();
|
2003-10-29 13:58:07 +00:00
|
|
|
continue;
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
2002-03-25 08:13:52 +00:00
|
|
|
} else if (SelectResult == 0) {
|
2003-11-03 13:57:11 +00:00
|
|
|
if ((me.now - me.lastmsg) > 180) {
|
2002-03-25 08:13:52 +00:00
|
|
|
/* if we havnt had a message for 3 minutes, more than likely, we are on a zombie server */
|
|
|
|
/* disconnect and try to reconnect */
|
2003-07-30 13:58:22 +00:00
|
|
|
nlog (LOG_WARNING, LOG_CORE, "Eeek, Zombie Server, Reconnecting");
|
2003-11-03 13:57:11 +00:00
|
|
|
return;
|
2002-03-25 08:13:52 +00:00
|
|
|
}
|
2000-03-02 01:31:24 +00:00
|
|
|
} else if (SelectResult == -1) {
|
2003-06-13 13:11:50 +00:00
|
|
|
if (errno != EINTR) {
|
2003-07-30 13:58:22 +00:00
|
|
|
nlog (LOG_WARNING, LOG_CORE, "Lost connection to server.");
|
2003-06-13 13:11:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
|
|
|
}
|
2003-07-30 13:58:22 +00:00
|
|
|
nlog (LOG_NORMAL, LOG_CORE, "hu, how did we get here");
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
2002-07-30 04:26:28 +00:00
|
|
|
|
2003-10-09 18:55:32 +00:00
|
|
|
/** @brief get max available sockets
|
|
|
|
*
|
|
|
|
* @param none
|
|
|
|
*
|
|
|
|
* @return returns the max available socket
|
|
|
|
*/
|
|
|
|
int
|
2003-07-30 13:58:22 +00:00
|
|
|
getmaxsock ()
|
2003-06-13 13:11:50 +00:00
|
|
|
{
|
2002-07-30 04:26:28 +00:00
|
|
|
struct rlimit *lim;
|
|
|
|
int ret;
|
2003-11-03 13:57:11 +00:00
|
|
|
|
2003-07-30 13:58:22 +00:00
|
|
|
lim = malloc (sizeof (struct rlimit));
|
|
|
|
getrlimit (RLIMIT_NOFILE, lim);
|
2003-06-13 13:11:50 +00:00
|
|
|
ret = lim->rlim_max;
|
2003-07-30 13:58:22 +00:00
|
|
|
free (lim);
|
2002-07-30 04:26:28 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-10-09 18:55:32 +00:00
|
|
|
/** @brief recv logging for all data received by us
|
|
|
|
*
|
|
|
|
* @param line of text received
|
|
|
|
*
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
static void
|
2003-07-30 13:58:22 +00:00
|
|
|
recvlog (char *line)
|
2002-03-11 06:55:05 +00:00
|
|
|
{
|
|
|
|
FILE *logfile;
|
2003-11-03 13:57:11 +00:00
|
|
|
|
2003-10-10 14:40:20 +00:00
|
|
|
if ((logfile = fopen (RECV_LOG, "a")) == NULL)
|
2003-06-13 13:11:50 +00:00
|
|
|
return;
|
2002-03-11 06:55:05 +00:00
|
|
|
if (logfile)
|
2004-05-28 09:51:47 +00:00
|
|
|
fprintf (logfile, "%s", line);
|
2003-07-30 13:58:22 +00:00
|
|
|
fclose (logfile);
|
2002-03-11 06:55:05 +00:00
|
|
|
}
|
2003-06-13 13:11:50 +00:00
|
|
|
|
2003-10-09 18:55:32 +00:00
|
|
|
/** @brief connect to a socket
|
|
|
|
*
|
|
|
|
* @param socktype type of socket
|
|
|
|
* @param ipaddr ip address of target
|
|
|
|
* @param port to connect to
|
|
|
|
* @param sockname name of this socket
|
|
|
|
* @param module name of the module
|
|
|
|
* @param func_read read socket function
|
|
|
|
* @param func_write write socket function
|
|
|
|
* @param func_error socket error function
|
|
|
|
*
|
2003-11-03 13:57:11 +00:00
|
|
|
* @return socket number if connect successful
|
|
|
|
* NS_FAILURE if unsuccessful
|
2003-10-09 18:55:32 +00:00
|
|
|
*/
|
2003-07-30 13:58:22 +00:00
|
|
|
int
|
|
|
|
sock_connect (int socktype, unsigned long ipaddr, int port, char *sockname, char *module, char *func_read, char *func_write, char *func_error)
|
2003-06-13 13:11:50 +00:00
|
|
|
{
|
2002-08-28 09:11:47 +00:00
|
|
|
struct sockaddr_in sa;
|
|
|
|
int s;
|
|
|
|
int i;
|
|
|
|
|
2003-11-03 13:57:11 +00:00
|
|
|
/* socktype = SOCK_STREAM */
|
2003-07-30 13:58:22 +00:00
|
|
|
if ((s = socket (AF_INET, socktype, 0)) < 0)
|
2003-11-03 13:57:11 +00:00
|
|
|
return NS_FAILURE;
|
2003-04-10 06:06:10 +00:00
|
|
|
|
2003-10-07 14:26:21 +00:00
|
|
|
/* bind to an IP address */
|
2003-04-10 06:06:10 +00:00
|
|
|
if (dobind > 0) {
|
2003-07-30 13:58:22 +00:00
|
|
|
if (bind (s, (struct sockaddr *) &lsa, sizeof (lsa)) < 0) {
|
|
|
|
nlog (LOG_WARNING, LOG_CORE, "sock_connect(): Warning, Couldn't bind to IP address %s", strerror (errno));
|
2003-04-10 06:06:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-30 13:58:22 +00:00
|
|
|
bzero (&sa, sizeof (sa));
|
2002-08-28 09:11:47 +00:00
|
|
|
sa.sin_family = AF_INET;
|
2003-07-30 13:58:22 +00:00
|
|
|
sa.sin_port = htons (port);
|
2002-08-28 09:11:47 +00:00
|
|
|
sa.sin_addr.s_addr = ipaddr;
|
|
|
|
|
|
|
|
/* set non blocking */
|
2003-06-13 13:11:50 +00:00
|
|
|
|
2003-07-30 13:58:22 +00:00
|
|
|
if ((i = fcntl (s, F_SETFL, O_NONBLOCK)) < 0) {
|
|
|
|
nlog (LOG_CRITICAL, LOG_CORE, "can't set socket %s(%s) non-blocking: %s", sockname, module, strerror (i));
|
2003-11-03 13:57:11 +00:00
|
|
|
return NS_FAILURE;
|
2002-08-28 09:11:47 +00:00
|
|
|
}
|
|
|
|
|
2003-07-30 13:58:22 +00:00
|
|
|
if ((i = connect (s, (struct sockaddr *) &sa, sizeof (sa))) < 0) {
|
2002-08-28 09:11:47 +00:00
|
|
|
switch (errno) {
|
2003-06-13 13:11:50 +00:00
|
|
|
case EINPROGRESS:
|
|
|
|
break;
|
|
|
|
default:
|
2003-12-03 15:32:14 +00:00
|
|
|
nlog (LOG_WARNING, LOG_CORE, "Socket %s(%s) cant connect %s", sockname, module, strerror (errno));
|
2003-07-30 13:58:22 +00:00
|
|
|
close (s);
|
2003-11-03 13:57:11 +00:00
|
|
|
return NS_FAILURE;
|
2002-08-28 09:11:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-30 13:58:22 +00:00
|
|
|
add_socket (func_read, func_write, func_error, sockname, s, module);
|
2002-08-28 09:11:47 +00:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2003-10-09 18:55:32 +00:00
|
|
|
/** @brief disconnect socket
|
|
|
|
*
|
|
|
|
* @param name of socket to disconnect
|
|
|
|
*
|
2003-11-03 13:57:11 +00:00
|
|
|
* @return NS_SUCCESS if disconnect successful
|
|
|
|
* NS_FAILURE if unsuccessful
|
2003-10-09 18:55:32 +00:00
|
|
|
*/
|
2003-07-30 13:58:22 +00:00
|
|
|
int
|
|
|
|
sock_disconnect (char *sockname)
|
2003-06-13 13:11:50 +00:00
|
|
|
{
|
2003-11-18 11:51:09 +00:00
|
|
|
ModSock *mod_sock;
|
2002-08-28 09:11:47 +00:00
|
|
|
fd_set fds;
|
2003-06-13 13:11:50 +00:00
|
|
|
struct timeval tv;
|
2002-08-28 09:11:47 +00:00
|
|
|
int i;
|
|
|
|
|
2003-11-18 11:51:09 +00:00
|
|
|
mod_sock = findsock (sockname);
|
|
|
|
if (!mod_sock) {
|
2003-07-30 13:58:22 +00:00
|
|
|
nlog (LOG_WARNING, LOG_CORE, "Warning, Can not find Socket %s in list", sockname);
|
2003-11-03 13:57:11 +00:00
|
|
|
return NS_FAILURE;
|
2002-08-28 09:11:47 +00:00
|
|
|
}
|
2003-06-13 13:11:50 +00:00
|
|
|
|
2002-08-28 09:11:47 +00:00
|
|
|
/* the following code makes sure its a valid file descriptor */
|
2003-07-30 13:58:22 +00:00
|
|
|
FD_ZERO (&fds);
|
2003-11-18 11:51:09 +00:00
|
|
|
FD_SET (mod_sock->sock_no, &fds);
|
2002-08-28 09:11:47 +00:00
|
|
|
tv.tv_sec = 0;
|
|
|
|
tv.tv_usec = 0;
|
2003-07-30 13:58:22 +00:00
|
|
|
i = select (1, &fds, NULL, NULL, &tv);
|
2002-08-28 09:11:47 +00:00
|
|
|
if (!i && errno == EBADF) {
|
2003-07-30 13:58:22 +00:00
|
|
|
nlog (LOG_WARNING, LOG_CORE, "Warning, Bad File Descriptor %s in list", sockname);
|
2003-11-03 13:57:11 +00:00
|
|
|
return NS_FAILURE;
|
2002-08-28 09:11:47 +00:00
|
|
|
}
|
2003-11-18 11:51:09 +00:00
|
|
|
nlog (LOG_DEBUG3, LOG_CORE, "Closing Socket %s with Number %d", sockname, mod_sock->sock_no);
|
|
|
|
close (mod_sock->sock_no);
|
2003-07-30 13:58:22 +00:00
|
|
|
del_socket (sockname);
|
2003-11-03 13:57:11 +00:00
|
|
|
return NS_SUCCESS;
|
2002-08-28 09:11:47 +00:00
|
|
|
}
|
2003-06-26 05:25:09 +00:00
|
|
|
|
2003-10-09 18:55:32 +00:00
|
|
|
/** @brief send to socket
|
|
|
|
*
|
|
|
|
* @param fmt printf style vaarg list of text to send
|
|
|
|
*
|
|
|
|
* @return none
|
|
|
|
*/
|
2003-07-30 13:58:22 +00:00
|
|
|
void
|
2004-02-04 22:59:41 +00:00
|
|
|
sts (const char *buf, const int buflen)
|
2003-06-26 05:25:09 +00:00
|
|
|
{
|
|
|
|
int sent;
|
2004-02-04 22:59:41 +00:00
|
|
|
|
2003-11-21 10:42:50 +00:00
|
|
|
if (servsock == -1) {
|
2004-02-04 22:59:41 +00:00
|
|
|
nlog(LOG_WARNING, LOG_CORE, "Not sending to server as we have a invalid socket");
|
2003-11-21 10:42:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-11-03 13:57:11 +00:00
|
|
|
sent = write (servsock, buf, buflen);
|
2003-06-26 05:25:09 +00:00
|
|
|
if (sent == -1) {
|
2003-09-22 14:21:09 +00:00
|
|
|
nlog (LOG_CRITICAL, LOG_CORE, "Write error: %s", strerror(errno));
|
2004-06-30 22:35:38 +00:00
|
|
|
close (servsock);
|
2004-06-30 22:34:22 +00:00
|
|
|
servsock = -1;
|
2003-11-03 13:57:11 +00:00
|
|
|
do_exit (NS_EXIT_ERROR, NULL);
|
2003-06-26 05:25:09 +00:00
|
|
|
}
|
|
|
|
me.SendM++;
|
|
|
|
me.SendBytes = me.SendBytes + sent;
|
|
|
|
}
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
|
|
|
|
#if SQLSRV
|
|
|
|
/* the following functions are taken from the RTA example app shipped with the library,
|
|
|
|
* and modified to work with NeoStats.
|
|
|
|
* Credit for these apps should be given to the respective authors of the RTA library.
|
|
|
|
* more info can be found at http://www.linuxappliancedesign.com for more
|
|
|
|
* information
|
|
|
|
*/
|
|
|
|
|
2003-12-28 07:23:42 +00:00
|
|
|
/* rehash handler */
|
|
|
|
int check_sql_sock() {
|
|
|
|
if (sqlListenSock < 1) {
|
|
|
|
nlog(LOG_DEBUG1, LOG_CORE, "Rehashing SQL sock");
|
|
|
|
sqlListenSock = sqllisten_on_port(me.sqlport);
|
|
|
|
if (sqlListenSock == -1) {
|
|
|
|
nlog(LOG_CRITICAL, LOG_CORE, "Failed to Setup Sql Port. SQL not available");
|
|
|
|
return NS_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************
|
|
|
|
* listen_on_port(int port): - Open a socket to listen for
|
|
|
|
* incoming TCP connections on the port given. Return the file
|
|
|
|
* descriptor if OK, and -1 on any error. The calling routine
|
|
|
|
* can handle any error condition.
|
|
|
|
*
|
|
|
|
* Input: The interger value of the port number to bind to
|
|
|
|
* Output: The file descriptor of the socket
|
|
|
|
* Effects: none
|
|
|
|
***************************************************************/
|
|
|
|
int
|
|
|
|
sqllisten_on_port(int port)
|
|
|
|
{
|
|
|
|
int srvfd; /* FD for our listen server socket */
|
|
|
|
struct sockaddr_in srvskt;
|
|
|
|
int adrlen;
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
adrlen = sizeof(struct sockaddr_in);
|
|
|
|
(void) memset((void *) &srvskt, 0, (size_t) adrlen);
|
|
|
|
srvskt.sin_family = AF_INET;
|
|
|
|
/* bind to the local IP */
|
|
|
|
if (dobind) {
|
|
|
|
srvskt.sin_addr = lsa.sin_addr;
|
|
|
|
} else {
|
|
|
|
srvskt.sin_addr.s_addr = INADDR_ANY;
|
|
|
|
}
|
|
|
|
srvskt.sin_port = htons(me.sqlport);
|
|
|
|
if ((srvfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
|
|
|
{
|
|
|
|
nlog(LOG_CRITICAL,LOG_CORE, "SqlSrv: Unable to get socket for port %d.", port);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
flags = fcntl(srvfd, F_GETFL, 0);
|
|
|
|
flags |= O_NONBLOCK;
|
|
|
|
(void) fcntl(srvfd, F_SETFL, flags);
|
|
|
|
if (bind(srvfd, (struct sockaddr *) &srvskt, adrlen) < 0)
|
|
|
|
{
|
2003-12-28 07:23:42 +00:00
|
|
|
nlog(LOG_CRITICAL, LOG_CORE, "Unable to bind to port %d", port);
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (listen(srvfd, 1) < 0)
|
|
|
|
{
|
2003-12-28 07:23:42 +00:00
|
|
|
nlog(LOG_CRITICAL, LOG_CORE, "Unable to listen on port %d", port);
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return (srvfd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************
|
|
|
|
* accept_ui_session(): - Accept a new UI/DB/manager session.
|
|
|
|
* This routine is called when a user interface program such
|
|
|
|
* as Apache (for the web interface), the SNMP manager, or one
|
|
|
|
* of the console interface programs tries to connect to the
|
|
|
|
* data base interface socket to do DB like get's and set's.
|
|
|
|
* The connection is actually established by the PostgreSQL
|
|
|
|
* library attached to the UI program by an XXXXXX call.
|
|
|
|
*
|
|
|
|
* Input: The file descriptor of the DB server socket
|
|
|
|
* Output: none
|
|
|
|
* Effects: manager connection table (ui)
|
|
|
|
***************************************************************/
|
|
|
|
void
|
|
|
|
sql_accept_conn(int srvfd)
|
|
|
|
{
|
|
|
|
int adrlen; /* length of an inet socket address */
|
|
|
|
int flags; /* helps set non-blocking IO */
|
|
|
|
lnode_t *newuinode;
|
|
|
|
Sql_Conn *newui;
|
|
|
|
char tmp[16];
|
|
|
|
|
|
|
|
/* if we reached our max connection, just exit */
|
|
|
|
if (list_count(sqlconnections) > 5) {
|
|
|
|
nlog(LOG_NOTICE, LOG_CORE, "Can not accept new SQL connection. Full");
|
|
|
|
close (srvfd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have a new UI/DB/manager connection request. So make a free
|
|
|
|
slot and allocate it */
|
|
|
|
newui = malloc(sizeof(Sql_Conn));
|
|
|
|
|
|
|
|
|
|
|
|
/* OK, we've got the ui slot, now accept the conn */
|
|
|
|
adrlen = sizeof(struct sockaddr_in);
|
|
|
|
newui->fd = accept(srvfd, (struct sockaddr *) &newui->cliskt, &adrlen);
|
|
|
|
|
|
|
|
if (newui->fd < 0)
|
|
|
|
{
|
2003-12-28 07:23:42 +00:00
|
|
|
nlog(LOG_WARNING, LOG_CORE, "SqlSrv: Manager accept() error (%s). \n", strerror(errno));
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
free(newui);
|
|
|
|
close(srvfd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inet_ntop(AF_INET, &newui->cliskt.sin_addr.s_addr, tmp, 16);
|
2004-01-30 10:55:48 +00:00
|
|
|
if (!match(me.sqlhost, tmp)) {
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
/* we didnt get a match, bye bye */
|
|
|
|
nlog(LOG_NOTICE, LOG_CORE, "SqlSrv: Rejecting SQL Connection from %s", tmp);
|
|
|
|
close(newui->fd);
|
|
|
|
free(newui);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* inc number ui, then init new ui */
|
|
|
|
flags = fcntl(newui->fd, F_GETFL, 0);
|
|
|
|
flags |= O_NONBLOCK;
|
|
|
|
(void) fcntl(newui->fd, F_SETFL, flags);
|
|
|
|
newui->cmdpos = 0;
|
|
|
|
newui->responsefree = 50000; /* max response packetsize if 50000 */
|
|
|
|
newui->nbytein = 0;
|
|
|
|
newui->nbyteout = 0;
|
|
|
|
newuinode = lnode_create(newui);
|
|
|
|
list_append(sqlconnections, newuinode);
|
|
|
|
inet_ntop(AF_INET, &newui->cliskt.sin_addr.s_addr, tmp, 16);
|
2003-12-28 07:23:42 +00:00
|
|
|
nlog(LOG_DEBUG1, LOG_CORE, "New SqlConnection from %s", tmp);
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************
|
|
|
|
* handle_ui_request(): - This routine is called to read data
|
|
|
|
* from the TCP connection to the UI programs such as the web
|
|
|
|
* UI and consoles. The protocol used is that of Postgres and
|
|
|
|
* the data is an encoded SQL request to select or update a
|
|
|
|
* system variable. Note that the use of callbacks on reading
|
|
|
|
* or writing means a lot of the operation of the program
|
|
|
|
* starts from this execution path. The input is an index into
|
|
|
|
* the ui table for the manager with data ready.
|
|
|
|
*
|
|
|
|
* Input: index of the relevant entry in the ui table
|
|
|
|
* Output: none
|
|
|
|
* Effects: many, many side effects via table callbacks
|
|
|
|
***************************************************************/
|
|
|
|
int
|
|
|
|
sql_handle_ui_request(lnode_t *sqlnode)
|
|
|
|
{
|
|
|
|
int ret; /* a return value */
|
|
|
|
int dbstat; /* a return value */
|
|
|
|
int t; /* a temp int */
|
|
|
|
Sql_Conn *sqlconn;
|
|
|
|
|
|
|
|
if ((sqlconn = lnode_get(sqlnode)) == NULL) {
|
|
|
|
nlog(LOG_WARNING, LOG_CORE, "Got a Sql Handle without a valid node");
|
|
|
|
return NS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* We read data from the connection into the buffer in the ui struct.
|
|
|
|
Once we've read all of the data we can, we call the DB routine to
|
|
|
|
parse out the SQL command and to execute it. */
|
|
|
|
ret = read(sqlconn->fd,
|
|
|
|
&(sqlconn->cmd[sqlconn->cmdpos]), (1000 - sqlconn->cmdpos));
|
|
|
|
|
|
|
|
/* shutdown manager conn on error or on zero bytes read */
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
/* log this since a normal close is with an 'X' command from the
|
|
|
|
client program? */
|
|
|
|
nlog(LOG_DEBUG1, LOG_CORE, "Disconnecting SqlClient for failed read");
|
2003-12-28 07:23:42 +00:00
|
|
|
deldbconnection(sqlconn->fd);
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
close(sqlconn->fd);
|
|
|
|
list_delete(sqlconnections, sqlnode);
|
|
|
|
lnode_destroy(sqlnode);
|
|
|
|
free(sqlconn);
|
|
|
|
return NS_FAILURE;
|
|
|
|
}
|
|
|
|
sqlconn->cmdpos += ret;
|
|
|
|
sqlconn->nbytein += ret;
|
|
|
|
|
|
|
|
/* The commands are in the buffer. Call the DB to parse and execute
|
|
|
|
them */
|
|
|
|
do
|
|
|
|
{
|
|
|
|
t = sqlconn->cmdpos, /* packet in length */
|
2003-12-16 12:39:54 +00:00
|
|
|
dbstat = dbcommand((char *)sqlconn->cmd, /* packet in */
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
&sqlconn->cmdpos, /* packet in length */
|
2003-12-28 07:23:42 +00:00
|
|
|
&sqlconn->response[50000 - sqlconn->responsefree], &sqlconn->responsefree, sqlconn->fd);
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
t -= sqlconn->cmdpos, /* t = # bytes consumed */
|
|
|
|
/* move any trailing SQL cmd text up in the buffer */
|
|
|
|
(void) memmove(sqlconn->cmd, &sqlconn->cmd[t], t);
|
|
|
|
} while (dbstat == RTA_SUCCESS);
|
|
|
|
if (dbstat == RTA_ERROR) {
|
2003-12-28 07:23:42 +00:00
|
|
|
deldbconnection(sqlconn->fd);
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
}
|
|
|
|
/* the command is done (including side effects). Send any reply back
|
|
|
|
to the UI */
|
|
|
|
sql_handle_ui_output(sqlnode);
|
|
|
|
return NS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************
|
|
|
|
* handle_ui_output() - This routine is called to write data
|
|
|
|
* to the TCP connection to the UI programs. It is useful for
|
|
|
|
* slow clients which can not accept the output in one big gulp.
|
|
|
|
*
|
|
|
|
* Input: index of the relevant entry in the ui table
|
|
|
|
* Output: none
|
|
|
|
* Effects: none
|
|
|
|
***************************************************************/
|
|
|
|
int
|
|
|
|
sql_handle_ui_output(lnode_t *sqlnode)
|
|
|
|
{
|
|
|
|
int ret; /* write() return value */
|
|
|
|
Sql_Conn *sqlconn;
|
|
|
|
|
|
|
|
if ((sqlconn = lnode_get(sqlnode)) == NULL) {
|
|
|
|
nlog(LOG_WARNING, LOG_CORE, "Got a Sql write Handle without a valid node");
|
|
|
|
return NS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sqlconn->responsefree < 50000)
|
|
|
|
{
|
|
|
|
ret = write(sqlconn->fd, sqlconn->response, (50000 - sqlconn->responsefree));
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
nlog(LOG_WARNING, LOG_CORE, "Got a write error when attempting to return data to the SQL Server");
|
2003-12-28 07:23:42 +00:00
|
|
|
deldbconnection(sqlconn->fd);
|
The sql code is integrated with the conf file, socket code, and initilization portions so far.
its not yet setup to export any of NeoStats structs, but you can test with this release with the built in tables:
to test:
./configure --enable-sqlsrv
add a line to neostats.cfg:
SQLSRV_AUTH Fish!blah@127.0.0.*
(username Fish, pass blah, host 127.0.0.* (IP only, can use wildcards)
compile and start up NeoStats
Check for any errors about unable to bind to ports etc.... (if you need to run on a diff port, add SQLSRV_PORT <portnum> to the neostats.cfg
now that its running, from php/command line, connect to the BINDTO ip address (if using BINDTO) or 127.0.0.1 port 8888
eg: command line:
psql -U Fish -h localhost -p 8888
it should prompt with a password.
once connected, you can view available tables with:
"select * from rta_tables;"
some examples are:
"select * from pg_user;"
"select * from pg_conn;"
"select * from rta_stat;"
"select * from rta_dbg;"
"select * from rta_columns;"
Remember, only very basic SQL is supported
2003-12-11 15:37:05 +00:00
|
|
|
close(sqlconn->fd);
|
|
|
|
list_delete(sqlconnections, sqlnode);
|
|
|
|
lnode_destroy(sqlnode);
|
|
|
|
free(sqlconn);
|
|
|
|
return NS_FAILURE;
|
|
|
|
}
|
|
|
|
else if (ret == (50000 - sqlconn->responsefree))
|
|
|
|
{
|
|
|
|
sqlconn->responsefree = 50000;
|
|
|
|
sqlconn->nbyteout += ret;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* we had a partial write. Adjust the buffer */
|
|
|
|
(void) memmove(sqlconn->response, &sqlconn->response[ret],
|
|
|
|
(50000 - sqlconn->responsefree - ret));
|
|
|
|
sqlconn->responsefree += ret;
|
|
|
|
sqlconn->nbyteout += ret; /* # bytes sent on conn */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|