~mdw
/
fwd
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fwd.c: Check return code from `chdir'.
[fwd]
/
endpt.c
diff --git
a/endpt.c
b/endpt.c
index
348dd44
..
1fbf188
100644
(file)
--- a/
endpt.c
+++ b/
endpt.c
@@
-1,54
+1,30
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: endpt.c,v 1.1 1999/07/26 23:33:01 mdw Exp $
- *
* Generic endpoint abstraction
*
* (c) 1999 Straylight/Edgeware
*/
* Generic endpoint abstraction
*
* (c) 1999 Straylight/Edgeware
*/
-/*----- Licensing notice --------------------------------------------------*
+/*----- Licensing notice --------------------------------------------------*
*
*
- * This file is part of the `fw' port forwarder.
+ * This file is part of the `fw
d
' port forwarder.
*
*
- * `fw' is free software; you can redistribute it and/or modify
+ * `fw
d
' 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.
* 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.
- *
- * `fw' is distributed in the hope that it will be useful,
+ *
+ * `fw
d
' 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.
* 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
* You should have received a copy of the GNU General Public License
- * along with `fw'; if not, write to the Free Software Foundation,
+ * along with `fw
d
'; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/*----- Revision history --------------------------------------------------*
- *
- * $Log: endpt.c,v $
- * Revision 1.1 1999/07/26 23:33:01 mdw
- * Infrastructure for the new design.
- *
- */
-
-/*----- Header files ------------------------------------------------------*/
-
-#include "config.h"
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include "chan.h"
-#include "endpt.h"
+#include "fwd.h"
/*----- Data structures ---------------------------------------------------*/
/*----- Data structures ---------------------------------------------------*/
@@
-71,6
+47,7
@@
typedef struct chanpair {
typedef struct tango {
struct tango *next, *prev; /* A big list of all tangos */
endpt *a, *b; /* The two endpoints */
typedef struct tango {
struct tango *next, *prev; /* A big list of all tangos */
endpt *a, *b; /* The two endpoints */
+ char *desc; /* Description of the connection */
unsigned s; /* State of the connection */
chanpair *c; /* The pair of channels */
} tango;
unsigned s; /* State of the connection */
chanpair *c; /* The pair of channels */
} tango;
@@
-145,6
+122,10
@@
void endpt_kill(endpt *a)
*/
if (a->f & b->f & EPF_FILE) {
*/
if (a->f & b->f & EPF_FILE) {
+ if (t->c->ab.err)
+ fw_log(-1, "[%s] error: %s", t->desc, strerror(t->c->ab.err));
+ else if (t->c->ba.err)
+ fw_log(-1, "[%s] error: %s", t->desc, strerror(t->c->ba.err));
if (t->s & EPS_AB)
chan_close(&t->c->ab);
if (!(b->f & EPF_PENDING) && (t->s & EPS_BA))
if (t->s & EPS_AB)
chan_close(&t->c->ab);
if (!(b->f & EPF_PENDING) && (t->s & EPS_BA))
@@
-163,6
+144,8
@@
void endpt_kill(endpt *a)
t->prev->next = t->next;
else
tangos = t->next;
t->prev->next = t->next;
else
tangos = t->next;
+ if (t->desc)
+ xfree(t->desc);
DESTROY(t);
}
DESTROY(t);
}
@@
-191,6
+174,7
@@
void endpt_killall(void)
*
* Arguments: @endpt *a@ = pointer to first endpoint
* @endpt *b@ = pointer to second endpoint
*
* Arguments: @endpt *a@ = pointer to first endpoint
* @endpt *b@ = pointer to second endpoint
+ * @const char *desc@ = description of connection
*
* Returns: ---
*
*
* Returns: ---
*
@@
-198,9
+182,13
@@
void endpt_killall(void)
* which are already joined; in fact, the the right thing to do
* when your endpoint decides that it's not pending any more is
* to join it to its partner again.
* which are already joined; in fact, the the right thing to do
* when your endpoint decides that it's not pending any more is
* to join it to its partner again.
+ *
+ * If the endpoints are already connected then the description
+ * string is ignored. The endpoint manager takes a copy of the
+ * string, so you don't need to keep it around.
*/
*/
-void endpt_join(endpt *a, endpt *b)
+void endpt_join(endpt *a, endpt *b
, const char *desc
)
{
tango *t = a->t;
{
tango *t = a->t;
@@
-215,6
+203,7
@@
void endpt_join(endpt *a, endpt *b)
a->t = b->t = t;
t->s = EPS_AB | EPS_BA;
t->c = 0;
a->t = b->t = t;
t->s = EPS_AB | EPS_BA;
t->c = 0;
+ t->desc = xstrdup(desc);
if (tangos)
tangos->prev = t;
tangos = t;
if (tangos)
tangos->prev = t;
tangos = t;
@@
-324,11
+313,14
@@
void endpt_join(endpt *a, endpt *b)
e = a; a = b; b = e;
}
e = a; a = b; b = e;
}
- /* --- Attach the non-file endpoint to the file and run away --- */
+ /* --- Attach the non-file endpoint to the file and run away --- *
+ *
+ * Leave it as the non-file's responsibility to close the other endpoint
+ * when it's ready. It should also close itself at that time.
+ */
b->ops->attach(b, a->in, a->out);
b->ops->attach(b, a->in, a->out);
- a->ops->close(a);
- b->ops->close(b);
+ b->ops->file(b, a);
if (t->next)
t->next->prev = t->prev;
if (t->prev)
if (t->next)
t->next->prev = t->prev;
if (t->prev)
@@
-369,6
+361,6
@@
void endpt_join(endpt *a, endpt *b)
chan_open(&t->c->ab, a->in->fd, b->out->fd, doneab, t);
chan_open(&t->c->ba, b->in->fd, a->out->fd, doneba, t);
return;
chan_open(&t->c->ab, a->in->fd, b->out->fd, doneab, t);
chan_open(&t->c->ba, b->in->fd, a->out->fd, doneba, t);
return;
-}
+}
/*----- That's all, folks -------------------------------------------------*/
/*----- That's all, folks -------------------------------------------------*/