Revision: 487
http://vde.svn.sourceforge.net/vde/?rev=487&view=rev
Author: rd235
Date: 2011-04-04 17:03:13 +0000 (Mon, 04 Apr 2011)
Log Message:
-----------
experimental vdeplug code P2P: connected sockets
Modified Paths:
--------------
branches/rd235/vde-2/src/lib/libvdeplug.c
Modified: branches/rd235/vde-2/src/lib/libvdeplug.c
===================================================================
--- branches/rd235/vde-2/src/lib/libvdeplug.c 2011-04-04 09:03:07 UTC (rev
486)
+++ branches/rd235/vde-2/src/lib/libvdeplug.c 2011-04-04 17:03:13 UTC (rev
487)
@@ -38,6 +38,7 @@
#include <vdecommon.h>
#include <libvdeplug.h>
+#define CONNECTED_P2P
/* Per-User standard switch definition */
/* This will be prefixed by getenv("HOME") */
@@ -513,17 +514,56 @@
ssize_t vde_recv(VDECONN *conn,void *buf,size_t len,int flags)
{
+#ifdef CONNECTED_P2P
+ ssize_t retval;
+ if (__builtin_expect(conn!=0,1)) {
+ if (__builtin_expect(((retval=recv(conn->fddata,buf,len,0)) >
0), 1))
+ return retval;
+ else {
+ if (retval == 0 && conn->outpath != NULL) {
+ static struct sockaddr unspec={AF_UNSPEC};
+ connect(conn->fddata,&unspec,sizeof(unspec));
+ }
+ return retval;
+ }
+ }
+ else {
+ errno=EBADF;
+ return -1;
+ }
+#else
if (__builtin_expect(conn!=0,1))
return recv(conn->fddata,buf,len,0);
else {
errno=EBADF;
return -1;
}
+#endif
}
ssize_t vde_send(VDECONN *conn,const void *buf,size_t len,int flags)
{
+#ifdef CONNECTED_P2P
if (__builtin_expect(conn!=0,1)) {
+ ssize_t retval;
+ if (__builtin_expect(((retval=send(conn->fddata,buf,len,0)) >=
0),1))
+ return retval;
+ else {
+ if (__builtin_expect(errno == ENOTCONN,0)) {
+ if (__builtin_expect(conn->outpath != NULL,1)) {
+ connect(conn->fddata, (struct sockaddr
*)conn->outpath,sizeof(conn->inpath));
+ return send(conn->fddata,buf,len,0);
+ } else
+ return retval;
+ } else
+ return retval;
+ }
+ } else {
+ errno=EBADF;
+ return -1;
+ }
+#else
+ if (__builtin_expect(conn!=0,1)) {
if (__builtin_expect(conn->outpath == NULL,1))
return send(conn->fddata,buf,len,0);
else
@@ -533,6 +573,7 @@
errno=EBADF;
return -1;
}
+#endif
}
int vde_datafd(VDECONN *conn)
@@ -558,6 +599,9 @@
int vde_close(VDECONN *conn)
{
if (__builtin_expect(conn!=0,1)) {
+#ifdef CONNECTED_P2P
+ send(conn->fddata,NULL,0,0);
+#endif
if (*(conn->inpath.sun_path))
unlink(conn->inpath.sun_path);
if (conn->outpath != NULL)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself;
WebMatrix provides all the features you need to develop and
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
vde-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vde-users