]> andersk Git - moira.git/blobdiff - gdb/gdb_conn.c
fix RCS Id strings
[moira.git] / gdb / gdb_conn.c
index cecc0b99bd798af0f327f9bb9e03157253cfb084..ba5b5c7a9d0f2d8696484b1e74f14e587b0b1e6e 100644 (file)
@@ -1,56 +1,34 @@
 /*
- *     $Source$
- *     $Header$
+ * $Source$
+ * $Header$
  */
 
 #ifndef lint
 static char *rcsid_gdb_conn_c = "$Header$";
-#endif lint
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+#endif
 
-/************************************************************************/
-/*     
-/*                        gdb_conn.c
-/*     
-/*           GDB - Connection Management Services
-/*     
-/*     Author: Noah Mendelsohn
-/*     Copyright: 1986 MIT Project Athena 
-/*             For copying and distribution information, please see
-/*             the file <mit-copyright.h>.
-/*     
-/*     Routines used in the creation and maintenance of CONNECTIONS.
-/*     Note: these are closely related to the services provided
-/*     by gdb_trans.c and gdb_trans2.c.
-/*     
-/*     
-/************************************************************************/
+/************************************************************************
+ *     
+ *                        gdb_conn.c
+ *     
+ *           GDB - Connection Management Services
+ *     
+ *     Author: Noah Mendelsohn
+ *     Copyright: 1986 MIT Project Athena 
+ *             For copying and distribution information, please see
+ *             the file <mit-copyright.h>.
+ *     
+ *     Routines used in the creation and maintenance of CONNECTIONS.
+ *     Note: these are closely related to the services provided
+ *     by gdb_trans.c and gdb_trans2.c.
+ *     
+ *     
+ ************************************************************************/
 
 #include <mit-copyright.h>
 #include <stdio.h>
-#include <strings.h>
+#include <stdlib.h>
+#include <string.h>
 #include "gdb.h"
 #include <sys/types.h>
 #include <sys/uio.h>
@@ -59,30 +37,33 @@ static char *rcsid_gdb_conn_c = "$Header$";
 #include <netinet/in.h>
 #include <netdb.h>
 #include <errno.h>
+#ifdef SOLARIS
+#include <sys/filio.h>
+#endif /* SOLARIS */
+#ifdef POSIX
+#include <unistd.h>
+#endif
 
 extern int errno;
-#ifdef vax
-extern u_short htons();                        /* ?? All versions?  */
-#endif vax
 
 CONNECTION gdb_allocate_connection();
 
-/************************************************************************/
-/*     
-/*                     start_peer_connection (start_peer_connection)
-/*     
-/*     Starts a connection to another process which itself will be 
-/*     issuing a start_peer_connection to us.  Current implementation
-/*     builds at most one stream, with the risk of a hang if 
-/*     the attempts to connect cross in the night.  This is a bug,
-/*     but this level of support is acceptable for casual debugging
-/*     of applications, and perhaps for some production use in
-/*     controlled settings.  I think the only other way to do it 
-/*     is to risk building two streams in parallel, possibly tearing
-/*     one down when the duplication is discovered.  Seems complicated
-/*     and messy.
-/*     
-/************************************************************************/
+/************************************************************************
+ *     
+ *                     start_peer_connection (start_peer_connection)
+ *     
+ *     Starts a connection to another process which itself will be 
+ *     issuing a start_peer_connection to us.  Current implementation
+ *     builds at most one stream, with the risk of a hang if 
+ *     the attempts to connect cross in the night.  This is a bug,
+ *     but this level of support is acceptable for casual debugging
+ *     of applications, and perhaps for some production use in
+ *     controlled settings.  I think the only other way to do it 
+ *     is to risk building two streams in parallel, possibly tearing
+ *     one down when the duplication is discovered.  Seems complicated
+ *     and messy.
+ *     
+ ************************************************************************/
 
 CONNECTION
 start_peer_connection(id)
@@ -143,7 +124,8 @@ char *id;                                   /* null terminated string */
        } else
                return NULL;
 }
-\f
+
+
 /************************************************************************/
 /*     
 /*                             g_make_con
@@ -174,7 +156,8 @@ g_make_con()
 
 }
 
-\f/************************************************************************/
+
+/************************************************************************/
 /*     
 /*                             g_null_con
 /*     
@@ -229,7 +212,7 @@ CONNECTION con;
 
 }
 
-\f
+
 /************************************************************************/
 /*     
 /*                     gdb_allocate_connection
@@ -270,7 +253,8 @@ gdb_allocate_connection()
        return &gdb_cons[i];                    /* return new highest con */
                                                /* ever used*/       
 }
-\f
+
+
 /************************************************************************/
 /*     
 /*                     g_try_connecting
@@ -291,6 +275,7 @@ char *id;
 {
        int peer;                               /* socket for talking to
                                                   peer */
+       char on = 1;                            /* flag for ioctl */
        struct sockaddr_in target;              /* build the peer address */
                                                /* here */
        struct hostent *peer_host;              /* host where peer is */
@@ -311,7 +296,7 @@ char *id;
        /*      
        /*----------------------------------------------------------*/
 
-       bzero((char *)&target, sizeof(target));
+       memset((char *)&target, 0, sizeof(target));
        g_parse_target(id, &peer_host, &target.sin_port);
        if (peer_host == NULL) {
                fprintf(gdb_log,"gdb: g_try_connecting...  '%s' is not a valid host:server\n",
@@ -341,7 +326,7 @@ char *id;
        /*----------------------------------------------------------*/
 
 
-       bcopy(peer_host->h_addr, (char *)&target.sin_addr, peer_host->h_length);
+       memcpy((char *)&target.sin_addr,peer_host->h_addr,peer_host->h_length);
        target.sin_family = peer_host->h_addrtype;
 
        /*----------------------------------------------------------*/
@@ -362,6 +347,13 @@ char *id;
                }
        }
 
+       if ((gdb_Options & GDB_OPT_KEEPALIVE) &&
+           setsockopt(peer, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)) < 0) {
+           gdb_perror("gdb: unable to start keepalives");
+           g_stop_with_errno(con);
+           return(TRUE);
+       }
+
        /*----------------------------------------------------------*/
        /*      
        /*      The connection has been made, fill in the connection
@@ -376,7 +368,8 @@ char *id;
        return TRUE;
 
 }
-\f
+
+
 /************************************************************************/
 /*     
 /*                     g_parse_target
@@ -480,7 +473,8 @@ u_short *port;
                *port = serv->s_port;
        }
 }
-\f
+
+
 /************************************************************************/
 /*     
 /*                     g_try_accepting
@@ -547,7 +541,7 @@ char *id;
        /*      
        /*----------------------------------------------------------*/
 
-       bzero((char *)&self, sizeof(self));
+       memset((char *)&self, 0, sizeof(self));
        g_parse_target(id, &peer_host, &self.sin_port);
        if (peer_host == NULL) {
                GDB_GIVEUP("gdb_try_accepting: bad port not caught by try connecting")
@@ -586,7 +580,7 @@ char *id;
                                                /* of pending non-accepted */
                                                /* cons.*/
        fromlen = sizeof(from);
-       peer = accept(slisten, &from, &fromlen);
+       peer = accept(slisten, (struct sockaddr *)&from, &fromlen);
        if (peer < 0) {
                g_stop_with_errno(con);
                gdb_perror("gdb_try_accepting: error accepting connection");
@@ -610,7 +604,8 @@ char *id;
        con->out.fd = peer;
        con->status = CON_STARTING;
 }
-\f
+
+
 /************************************************************************/
 /*     
 /*                     g_ver_oprotocol
@@ -659,11 +654,12 @@ CONNECTION con;
                con->status = CON_UP;
        else
                con->status = CON_STOPPED;
-#else !VERIFY_PROTOCOL
+#else
        con->status = CON_UP;
-#endif !VERIFY_PROTOCOL
+#endif
 }
 
+
 /************************************************************************/
 /*     
 /*                     g_ver_iprotocol
@@ -712,12 +708,12 @@ CONNECTION con;
                g_stop_with_errno(con);
                return;
        }
-#else   !VERIFY_PROTOCOL
+#else
        con->status = CON_UP;
 #endif
 }
 
-\f
+
 /************************************************************************/
 /*     
 /*                     sever_connection (sever_connection)
@@ -747,6 +743,7 @@ CONNECTION con;
        return NULL;
 }
 
+
 /************************************************************************/
 /*     
 /*                     g_stop_with_errno
@@ -757,7 +754,6 @@ CONNECTION con;
 /*     
 /************************************************************************/
 
-
 int
 g_stop_with_errno(con)
 CONNECTION con;
@@ -767,6 +763,7 @@ CONNECTION con;
        
 }
 
+
 /************************************************************************/
 /*     
 /*                     g_stop_connection
@@ -817,7 +814,7 @@ CONNECTION con;
        return;
 }
 
-\f
+
 /************************************************************************/
 /*     
 /*                     gdb_de_allocate_connection
@@ -845,7 +842,8 @@ CONNECTION con;
 
        gdb_mcons = i + 1;
 }
-\f
+
+
 /************************************************************************/
 /*     
 /*                     g_cleanup_half_conection
@@ -878,7 +876,8 @@ HALF_CONNECTION hcon;
                current = next;
        }
 }
-\f
+
+
 /************************************************************************/
 /*     
 /*                 create_listening_connection (create_listening_connection)
@@ -969,7 +968,7 @@ char *id;
        /*      
        /*----------------------------------------------------------*/
 
-       bzero((char *)&self, sizeof(self));
+       memset((char *)&self, 0, sizeof(self));
        /*
         * Determine our port number
         */
@@ -1021,7 +1020,8 @@ char *id;
                gdb_mfd = con->in.fd + 1;
        return con;
 }
-\f
+
+
 /************************************************************************/
 /*     
 /*                     g_allocate_connection_buffers
This page took 0.051829 seconds and 4 git commands to generate.