summaryrefslogtreecommitdiffstats
path: root/c/src/librdbg/src/servcon.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2002-02-01 17:00:01 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2002-02-01 17:00:01 +0000
commit40cf43eab4e4121a92ec95bc1366cc5b3bad4e27 (patch)
tree5aef0f81416b68a9f035ac5d14ba9278f0787c1c /c/src/librdbg/src/servcon.c
parent2001-02-01 Mike Siers <mikes@poliac.com> (diff)
downloadrtems-40cf43eab4e4121a92ec95bc1366cc5b3bad4e27.tar.bz2
* So many patches have been posted recently on the mailing list and
because we were unable to find correct solution to compile on various linux distros (due to rpcgen incompatibilities), and because the coding style of rdbg was rather inconsistant among various pieces of code, I decided to: 1) make some cleaning regarding global coding style (using indent + manual edits), 2) incorporate/review the paches send by various people (S. Holford, T. Strauman), 3) Fix the bug due to varying rpcgen code generation in remdeb_svc.c, 4) Remove some dead code, 5) Apply a patches enabling to call enterRdbg imediately after rdbg initialization is done, NB : the paches is huge but it is mainly due to coding styke chnages. Only few lines of codes have been really changed and they do not impact rdbg functionnality (AFAIKT). * include/rdbg/servrpc.h, include/rdbg/i386/rdbg_f.h, include/rdbg/m68k/rdbg_f.h, include/rdbg/powerpc/rdbg_f.h, src/_servtgt.c, src/awk.svc, src/excep.c, src/ptrace.c, src/rdbg.c, src/remdeb.x, src/servbkpt.c, src/servcon.c, src/servrpc.c, src/servtgt.c, src/servtsp.c, src/servutil.c, src/i386/excep_f.c, src/i386/rdbg_f.c, src/i386/any/Makefile.am, src/i386/any/remdeb.h, src/i386/any/remdeb_svc.c, src/i386/any/remdeb_xdr.c, src/m68k/excep_f.c, src/m68k/rdbg_f.c, src/m68k/any/Makefile.am, src/m68k/any/remdeb.h, src/m68k/any/remdeb_svc.c, src/m68k/any/remdeb_xdr.c, src/powerpc/excep_f.c, src/powerpc/rdbg_f.c, src/powerpc/new_exception_processing/Makefile.am, src/powerpc/new_exception_processing/remdeb.h, src/powerpc/new_exception_processing/remdeb_svc.c, src/powerpc/new_exception_processing/remdeb_xdr.c: Modified.
Diffstat (limited to 'c/src/librdbg/src/servcon.c')
-rw-r--r--c/src/librdbg/src/servcon.c219
1 files changed, 118 insertions, 101 deletions
diff --git a/c/src/librdbg/src/servcon.c b/c/src/librdbg/src/servcon.c
index 30570760db..4660453f94 100644
--- a/c/src/librdbg/src/servcon.c
+++ b/c/src/librdbg/src/servcon.c
@@ -11,10 +11,10 @@
**************************************************************************
*/
-#include <sys/errno.h>
-#include <rdbg/rdbg.h>
-#include <rdbg/servrpc.h>
-
+#include <sys/errno.h>
+#include <rdbg/rdbg.h>
+#include <rdbg/servrpc.h>
+
/*
* ConnCreate - create a new connection entry for a client.
*
@@ -25,66 +25,74 @@
* the caller.
*/
- int
-ConnCreate (struct svc_req* rqstp, open_in* in)
+ int
+ConnCreate (struct svc_req *rqstp, open_in * in)
{
- NET_OPAQUE sender;
- int idx;
- CONN_LIST* clst;
-
- setErrno (0);
-
- /* Convert to valid Net address */
- if (! TspTranslateRpcAddr (rqstp, &sender)) {
- DPRINTF (("ConnCreate: TspTranslateRpcAddr failed\n"));
- return -1;
- }
- if (! TspValidateAddr ((NET_OPAQUE*) in->back_port, &sender)) {
- DPRINTF (("ConnCreate: TspValidateAddr failed\n"));
- return -1; /* errno now setup with error */
+ NET_OPAQUE sender;
+ int idx;
+ CONN_LIST *clst;
+
+ setErrno (0);
+
+ /*
+ * Convert to valid Net address
+ */
+ if (!TspTranslateRpcAddr (rqstp, &sender)) {
+ DPRINTF (("ConnCreate: TspTranslateRpcAddr failed\n"));
+ return -1;
+ }
+ if (!TspValidateAddr ((NET_OPAQUE *) in->back_port, &sender)) {
+ DPRINTF (("ConnCreate: TspValidateAddr failed\n"));
+ return -1; /* errno now setup with error */
+ }
+
+ /*
+ * look for an empty connection entry
+ */
+ for (idx = 0; idx < conn_list_cnt; idx++) {
+ if (!conn_list[idx].in_use)
+ break; /* an empty one found */
+ }
+
+ if (idx >= conn_list_cnt) { /* no empties, create space */
+ CONN_LIST *tmp_conn_list = conn_list;
+
+ conn_list_cnt += CONN_LIST_INC;
+ if (conn_list) {
+ conn_list = (CONN_LIST *) Realloc (conn_list, /* extend */
+ conn_list_cnt * sizeof (CONN_LIST));
+ } else {
+ conn_list = (CONN_LIST *) Malloc (conn_list_cnt * sizeof (CONN_LIST));
}
- /* look for an empty connection entry */
- for (idx = 0; idx < conn_list_cnt; idx++) {
- if (!conn_list[idx].in_use)
- break; /* an empty one found */
+ if (!conn_list) { /* unable to get space */
+ if ((conn_list_cnt -= CONN_LIST_INC)) {
+ /*
+ * was realloc, restore space
+ */
+ conn_list = tmp_conn_list;
+ }
+ return -1; /* errno set by failed alloc */
}
-
- if (idx >= conn_list_cnt) { /* no empties, create space */
- CONN_LIST* tmp_conn_list = conn_list;
-
- conn_list_cnt += CONN_LIST_INC;
- if (conn_list) {
- conn_list = (CONN_LIST *) Realloc (conn_list, /* extend */
- conn_list_cnt * sizeof (CONN_LIST));
- } else {
- conn_list = (CONN_LIST *)Malloc(conn_list_cnt * sizeof(CONN_LIST));
- }
-
- if (!conn_list) { /* unable to get space */
- if ((conn_list_cnt -= CONN_LIST_INC)) {
- /* was realloc, restore space */
- conn_list = tmp_conn_list;
- }
- return -1; /* errno set by failed alloc */
- }
- /* clear newly created memory */
- memset (conn_list + idx, 0, CONN_LIST_INC * sizeof (CONN_LIST));
- } else { /* clear new entry */
- memset (conn_list + idx, 0, sizeof (CONN_LIST));
- }
- clst = conn_list + idx;
-
- clst->in_use = True; /* now in use */
- clst->sender = sender;
- memcpy (&clst->back_port, &in->back_port, sizeof (NET_OPAQUE));
- memcpy (&clst->route, &in->destination, sizeof (NET_OPAQUE));
- clst->debug_type = (UCHAR) in->debug_type;
- clst->flags = in->flags;
- strncpy (clst->user_name, in->user_name, NAMEMAX-1);
- clst->user_name [NAMEMAX-1] = 0;
-
- return idx;
+ /*
+ * clear newly created memory
+ */
+ memset (conn_list + idx, 0, CONN_LIST_INC * sizeof (CONN_LIST));
+ } else { /* clear new entry */
+ memset (conn_list + idx, 0, sizeof (CONN_LIST));
+ }
+ clst = conn_list + idx;
+
+ clst->in_use = True; /* now in use */
+ clst->sender = sender;
+ memcpy (&clst->back_port, &in->back_port, sizeof (NET_OPAQUE));
+ memcpy (&clst->route, &in->destination, sizeof (NET_OPAQUE));
+ clst->debug_type = (UCHAR) in->debug_type;
+ clst->flags = in->flags;
+ strncpy (clst->user_name, in->user_name, NAMEMAX - 1);
+ clst->user_name[NAMEMAX - 1] = 0;
+
+ return idx;
}
/*
@@ -92,47 +100,56 @@ ConnCreate (struct svc_req* rqstp, open_in* in)
*
*/
- void
-ConnDelete (int conn, struct svc_req* rqstp, close_control control)
+ void
+ConnDelete (int conn, struct svc_req *rqstp, close_control control)
{
- CONN_LIST* clst = conn_list + conn;
- int idx;
- Boolean prim;
-
- if (! clst->in_use) return; /* not active */
-
- for (idx = 0; idx < pid_list_cnt; idx++) {
- PID_LIST* plst = pid_list + idx;
-
- if (! PIDMAP_TEST (conn, idx)) continue;
-
- /* found a controlled pid */
- prim = (plst->primary_conn == conn) ? True : False;
- TgtDetachCon (conn, idx, True);
-
- /* if still running or alive, we use close control on it */
- if (! plst->pid)
- continue; /* entry gone */
-
- if (prim && control == CLOSE_KILL) {
- /* kill off process */
- TgtKillAndDelete (plst, rqstp, True);
- } else if (! plst->owners) {
- /* no owners left */
- if (control == CLOSE_DETACH) {
- TgtKillAndDelete (plst, rqstp, False);
- }
- if (control == CLOSE_DETACH || PROC_TERMINATED (plst)) {
- TgtDelete (plst, conn, (control==CLOSE_DETACH) ?
- BMSG_DETACH : 0);
- }
- }
- }
- if (clst->list) {
- Free (clst->list); /* free allocated memory */
- }
- DPRINTF (("ConnDelete: Connection closed for port %u\n",
- HL_W(*((UINT16*) &clst->back_port.c[2]))));
+ CONN_LIST *clst = conn_list + conn;
+ int idx;
+ Boolean prim;
+
+ if (!clst->in_use)
+ return; /* not active */
- clst->in_use = False; /* free it back */
+ for (idx = 0; idx < pid_list_cnt; idx++) {
+ PID_LIST *plst = pid_list + idx;
+
+ if (!PIDMAP_TEST (conn, idx))
+ continue;
+
+ /*
+ * found a controlled pid
+ */
+ prim = (plst->primary_conn == conn) ? True : False;
+ TgtDetachCon (conn, idx, True);
+
+ /*
+ * if still running or alive, we use close control on it
+ */
+ if (!plst->pid)
+ continue; /* entry gone */
+
+ if (prim && control == CLOSE_KILL) {
+ /*
+ * kill off process
+ */
+ TgtKillAndDelete (plst, rqstp, True);
+ } else if (!plst->owners) {
+ /*
+ * no owners left
+ */
+ if (control == CLOSE_DETACH) {
+ TgtKillAndDelete (plst, rqstp, False);
+ }
+ if (control == CLOSE_DETACH || PROC_TERMINATED (plst)) {
+ TgtDelete (plst, conn, (control == CLOSE_DETACH) ? BMSG_DETACH : 0);
+ }
+ }
+ }
+ if (clst->list) {
+ Free (clst->list); /* free allocated memory */
+ }
+ DPRINTF (("ConnDelete: Connection closed for port %u\n",
+ HL_W (*((UINT16 *) & clst->back_port.c[2]))));
+
+ clst->in_use = False; /* free it back */
}