[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5364 - in GNUnet/src: applications/advertising application
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5364 - in GNUnet/src: applications/advertising applications/transport include server transports |
Date: |
Sun, 29 Jul 2007 01:14:25 -0600 (MDT) |
Author: grothoff
Date: 2007-07-29 01:14:25 -0600 (Sun, 29 Jul 2007)
New Revision: 5364
Modified:
GNUnet/src/applications/advertising/advertising.c
GNUnet/src/applications/transport/transport.c
GNUnet/src/include/gnunet_transport.h
GNUnet/src/include/gnunet_transport_service.h
GNUnet/src/server/gnunet-transport-check.c
GNUnet/src/transports/http.c
GNUnet/src/transports/nat.c
GNUnet/src/transports/tcp.c
GNUnet/src/transports/tcp6.c
GNUnet/src/transports/udp_helper.c
Log:
fixing HELLO verification
Modified: GNUnet/src/applications/advertising/advertising.c
===================================================================
--- GNUnet/src/applications/advertising/advertising.c 2007-07-29 06:48:51 UTC
(rev 5363)
+++ GNUnet/src/applications/advertising/advertising.c 2007-07-29 07:14:25 UTC
(rev 5364)
@@ -342,7 +342,7 @@
/* Establish session as advertised in the hello */
- tsession = transport->connect (msg, __FILE__);
+ tsession = transport->connect (msg, __FILE__, NO);
if (tsession == NULL)
{
if (stats != NULL)
@@ -493,7 +493,7 @@
#endif
return OK;
}
- tsession = transport->connect (hello, __FILE__);
+ tsession = transport->connect (hello, __FILE__, YES);
FREE (hello);
if (tsession == NULL)
{
Modified: GNUnet/src/applications/transport/transport.c
===================================================================
--- GNUnet/src/applications/transport/transport.c 2007-07-29 06:48:51 UTC
(rev 5363)
+++ GNUnet/src/applications/transport/transport.c 2007-07-29 07:14:25 UTC
(rev 5364)
@@ -224,10 +224,14 @@
* transport mechanism is not available.
*
* @param hello the hello of the target node
+ * @param may_reuse can an existing connection be
+ * re-used?
* @return session on success, NULL on error
*/
static TSession *
-transportConnect (const P2P_hello_MESSAGE * hello, const char *token)
+transportConnect (const P2P_hello_MESSAGE * hello,
+ const char *token,
+ int may_reuse)
{
unsigned short prot;
TSession *tsession;
@@ -243,7 +247,8 @@
return NULL;
}
tsession = NULL;
- if (OK != tapis[prot]->connect (hello, &tsession))
+ if (OK != tapis[prot]->connect (hello, &tsession,
+ may_reuse))
return NULL;
tsession->ttype = prot;
MUTEX_LOCK (lock);
@@ -278,7 +283,7 @@
if (hello == NULL)
continue;
hc++;
- ret = transportConnect (hello, token);
+ ret = transportConnect (hello, token, YES);
FREE (hello);
if (ret != NULL)
break;
Modified: GNUnet/src/include/gnunet_transport.h
===================================================================
--- GNUnet/src/include/gnunet_transport.h 2007-07-29 06:48:51 UTC (rev
5363)
+++ GNUnet/src/include/gnunet_transport.h 2007-07-29 07:14:25 UTC (rev
5364)
@@ -257,9 +257,11 @@
*
* @param hello the hello-Message for the target node
* @param tsession the session handle that is to be set
+ * @param may_reuse can an existing connection be re-used?
* @return OK on success, SYSERR if the operation failed
*/
- int (*connect) (const P2P_hello_MESSAGE * hello, TSession ** tsession);
+ int (*connect) (const P2P_hello_MESSAGE * hello, TSession ** tsession,
+ int may_reuse);
/**
* Send a message to the specified remote node.
Modified: GNUnet/src/include/gnunet_transport_service.h
===================================================================
--- GNUnet/src/include/gnunet_transport_service.h 2007-07-29 06:48:51 UTC
(rev 5363)
+++ GNUnet/src/include/gnunet_transport_service.h 2007-07-29 07:14:25 UTC
(rev 5364)
@@ -84,11 +84,14 @@
* not available.
*
* @param hello the hello of the target node
+ * @param may_reuse can an existing connection be
+ * re-used?
* @param token string identifying who is holding the reference
* (must match when disconnect is called)
* @return session handle on success, NULL on error
*/
- TSession *(*connect) (const P2P_hello_MESSAGE * hello, const char *token);
+ TSession *(*connect) (const P2P_hello_MESSAGE * hello, const char *token,
+ int may_reuse);
/**
* Connect to another peer, picking any transport that
Modified: GNUnet/src/server/gnunet-transport-check.c
===================================================================
--- GNUnet/src/server/gnunet-transport-check.c 2007-07-29 06:48:51 UTC (rev
5363)
+++ GNUnet/src/server/gnunet-transport-check.c 2007-07-29 07:14:25 UTC (rev
5364)
@@ -123,7 +123,7 @@
return;
}
tsession = NULL;
- if (OK != tapi->connect (helo, &tsession))
+ if (OK != tapi->connect (helo, &tsession, NO))
{
fprintf (stderr, _("`%s': Could not connect.\n"), tapi->transName);
*res = SYSERR;
@@ -269,7 +269,7 @@
fprintf (stderr, ".");
tsession = NULL;
peer = hello->senderIdentity;
- tsession = transport->connect (hello, __FILE__);
+ tsession = transport->connect (hello, __FILE__, NO);
FREE (hello);
if (tsession == NULL)
{
Modified: GNUnet/src/transports/http.c
===================================================================
--- GNUnet/src/transports/http.c 2007-07-29 06:48:51 UTC (rev 5363)
+++ GNUnet/src/transports/http.c 2007-07-29 07:14:25 UTC (rev 5364)
@@ -820,7 +820,8 @@
* @return OK on success, SYSERR if the operation failed
*/
static int
-httpConnect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr)
+httpConnect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr,
+ int may_reuse)
{
const HostAddress *haddr = (const HostAddress *) &hello[1];
TSession *tsession;
Modified: GNUnet/src/transports/nat.c
===================================================================
--- GNUnet/src/transports/nat.c 2007-07-29 06:48:51 UTC (rev 5363)
+++ GNUnet/src/transports/nat.c 2007-07-29 07:14:25 UTC (rev 5364)
@@ -109,7 +109,8 @@
* @return always fails (returns SYSERR)
*/
static int
-natConnect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr)
+natConnect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr,
+ int may_reuse)
{
return SYSERR;
}
Modified: GNUnet/src/transports/tcp.c
===================================================================
--- GNUnet/src/transports/tcp.c 2007-07-29 06:48:51 UTC (rev 5363)
+++ GNUnet/src/transports/tcp.c 2007-07-29 07:14:25 UTC (rev 5364)
@@ -309,7 +309,8 @@
* @return OK on success, SYSERR if the operation failed
*/
static int
-tcpConnect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr)
+tcpConnect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr,
+ int may_reuse)
{
static int zero = 0;
HostAddress *haddr;
@@ -321,27 +322,29 @@
if (selector == NULL)
return SYSERR;
- MUTEX_LOCK (tcplock);
- session = sessions;
- while (session != NULL)
- {
- if (0 == memcmp (&session->sender,
- &hello->senderIdentity, sizeof (PeerIdentity)))
- {
- MUTEX_LOCK (session->lock);
- if (session->in_select)
- {
- session->users++;
- MUTEX_UNLOCK (session->lock);
- MUTEX_UNLOCK (tcplock);
- *tsessionPtr = session->tsession;
- return OK;
- }
- MUTEX_UNLOCK (session->lock);
- }
- session = session->next;
- }
- MUTEX_UNLOCK (tcplock);
+ if (may_reuse != NO) {
+ MUTEX_LOCK (tcplock);
+ session = sessions;
+ while (session != NULL)
+ {
+ if (0 == memcmp (&session->sender,
+ &hello->senderIdentity, sizeof (PeerIdentity)))
+ {
+ MUTEX_LOCK (session->lock);
+ if (session->in_select)
+ {
+ session->users++;
+ MUTEX_UNLOCK (session->lock);
+ MUTEX_UNLOCK (tcplock);
+ *tsessionPtr = session->tsession;
+ return OK;
+ }
+ MUTEX_UNLOCK (session->lock);
+ }
+ session = session->next;
+ }
+ MUTEX_UNLOCK (tcplock);
+ }
haddr = (HostAddress *) & hello[1];
#if DEBUG_TCP
GE_LOG (ectx,
Modified: GNUnet/src/transports/tcp6.c
===================================================================
--- GNUnet/src/transports/tcp6.c 2007-07-29 06:48:51 UTC (rev 5363)
+++ GNUnet/src/transports/tcp6.c 2007-07-29 07:14:25 UTC (rev 5364)
@@ -261,7 +261,8 @@
* @return OK on success, SYSERR if the operation failed
*/
static int
-tcp6Connect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr)
+tcp6Connect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr,
+ int may_reuse)
{
int i;
Host6Address *haddr;
@@ -274,26 +275,28 @@
if (selector == NULL)
return SYSERR;
- MUTEX_LOCK (tcplock);
- session = sessions;
- while (session != NULL)
- {
- if (0 == memcmp (&session->sender,
- &hello->senderIdentity, sizeof (PeerIdentity)))
- {
- MUTEX_LOCK (session->lock);
- if (session->in_select)
- {
- session->users++;
- MUTEX_UNLOCK (session->lock);
- MUTEX_UNLOCK (tcplock);
- *tsessionPtr = session->tsession;
- return OK;
- }
- MUTEX_UNLOCK (session->lock);
- }
- session = session->next;
- }
+ if (NO != may_reuse) {
+ MUTEX_LOCK (tcplock);
+ session = sessions;
+ while (session != NULL)
+ {
+ if (0 == memcmp (&session->sender,
+ &hello->senderIdentity, sizeof (PeerIdentity)))
+ {
+ MUTEX_LOCK (session->lock);
+ if (session->in_select)
+ {
+ session->users++;
+ MUTEX_UNLOCK (session->lock);
+ MUTEX_UNLOCK (tcplock);
+ *tsessionPtr = session->tsession;
+ return OK;
+ }
+ MUTEX_UNLOCK (session->lock);
+ }
+ session = session->next;
+ }
+ }
MUTEX_UNLOCK (tcplock);
haddr = (Host6Address *) & hello[1];
memset (&hints, 0, sizeof (hints));
Modified: GNUnet/src/transports/udp_helper.c
===================================================================
--- GNUnet/src/transports/udp_helper.c 2007-07-29 06:48:51 UTC (rev 5363)
+++ GNUnet/src/transports/udp_helper.c 2007-07-29 07:14:25 UTC (rev 5364)
@@ -144,7 +144,8 @@
* @return OK on success, SYSERR if the operation failed
*/
static int
-udpConnect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr)
+udpConnect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr,
+ int may_reuse)
{
TSession *tsession;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5364 - in GNUnet/src: applications/advertising applications/transport include server transports,
gnunet <=