* This file is part of Portals, http://www.sf.net/projects/sandiaportals/
*/
+#ifndef TCPNAL_PROCBRIDGE_H
+#define TCPNAL_PROCBRIDGE_H
+
#include <portals/lib-p30.h>
typedef struct bridge {
typedef int (*nal_initialize)(bridge);
extern nal_initialize nal_table[PTL_IFACE_MAX];
+
+#endif
*/
connection force_tcp_connection(manager m,
unsigned int ip,
- unsigned short port)
+ unsigned short port,
+ procbridge pb)
{
connection conn;
struct sockaddr_in addr;
exit(-1);
conn = allocate_connection(m, ip, port, fd);
+
+ /* let nal thread know this event right away */
+ if (conn)
+ procbridge_wakeup_nal(pb);
}
pthread_mutex_unlock(&m->conn_lock);
*/
#include <table.h>
+#include <procbridge.h>
typedef struct manager {
table connections;
manager m;
} *connection;
-connection force_tcp_connection(manager m, unsigned int ip, unsigned int short);
+connection force_tcp_connection(manager m, unsigned int ip, unsigned int short,
+ procbridge pb);
manager init_connections(unsigned short, int (*f)(void *, void *), void *);
void remove_connection(void *arg);
void shutdown_connections(manager m);
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#ifndef __CYGWIN__
+#include <syscall.h>
+#endif
+#include <sys/socket.h>
#include <procbridge.h>
#include <pqtimer.h>
#include <dispatch.h>
#include <errno.h>
+/* XXX CFS workaround, to give a chance to let nal thread wake up
+ * from waiting in select
+ */
+static int procbridge_notifier_handler(void *arg)
+{
+ static char buf[8];
+ procbridge p = (procbridge) arg;
+
+ syscall(SYS_read, p->notifier[1], buf, sizeof(buf));
+ return 1;
+}
+
+void procbridge_wakeup_nal(procbridge p)
+{
+ static char buf[8];
+ syscall(SYS_write, p->notifier[0], buf, sizeof(buf));
+}
+
/* Function: forward
* Arguments: nal_t *nal: pointer to my top-side nal structure
* id: the command to pass to the lower layer
procbridge p=(procbridge)b->local;
p->nal_flags |= NAL_FLAG_STOPPING;
+ procbridge_wakeup_nal(p);
do {
pthread_mutex_lock(&p->mutex);
p->nal_flags = 0;
pthread_mutex_init(&p->nal_cb_lock, 0);
+ /* initialize notifier */
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, p->notifier)) {
+ perror("socketpair failed");
+ return NULL;
+ }
+
+ if (!register_io_handler(p->notifier[1], READ_HANDLER,
+ procbridge_notifier_handler, p)) {
+ perror("fail to register notifier handler");
+ return NULL;
+ }
+
+ /* create nal thread */
if (pthread_create(&p->t, NULL, nal_thread, &args)) {
perror("nal_init: pthread_create");
return(NULL);
pthread_cond_t cond;
pthread_mutex_t mutex;
+ /* socket pair used to notify nal thread */
+ int notifier[2];
+
int nal_flags;
pthread_mutex_t nal_cb_lock;
ptl_pt_index_t ptl_size,
ptl_ac_index_t acl_size,
ptl_pid_t requested_pid);
+extern void procbridge_wakeup_nal(procbridge p);
#endif
* This file is part of Portals, http://www.sf.net/projects/sandiaportals/
*/
+#ifndef TCPNAL_PROCBRIDGE_H
+#define TCPNAL_PROCBRIDGE_H
+
#include <portals/lib-p30.h>
typedef struct bridge {
typedef int (*nal_initialize)(bridge);
extern nal_initialize nal_table[PTL_IFACE_MAX];
+
+#endif
*/
connection force_tcp_connection(manager m,
unsigned int ip,
- unsigned short port)
+ unsigned short port,
+ procbridge pb)
{
connection conn;
struct sockaddr_in addr;
exit(-1);
conn = allocate_connection(m, ip, port, fd);
+
+ /* let nal thread know this event right away */
+ if (conn)
+ procbridge_wakeup_nal(pb);
}
pthread_mutex_unlock(&m->conn_lock);
*/
#include <table.h>
+#include <procbridge.h>
typedef struct manager {
table connections;
manager m;
} *connection;
-connection force_tcp_connection(manager m, unsigned int ip, unsigned int short);
+connection force_tcp_connection(manager m, unsigned int ip, unsigned int short,
+ procbridge pb);
manager init_connections(unsigned short, int (*f)(void *, void *), void *);
void remove_connection(void *arg);
void shutdown_connections(manager m);
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#ifndef __CYGWIN__
+#include <syscall.h>
+#endif
+#include <sys/socket.h>
#include <procbridge.h>
#include <pqtimer.h>
#include <dispatch.h>
#include <errno.h>
+/* XXX CFS workaround, to give a chance to let nal thread wake up
+ * from waiting in select
+ */
+static int procbridge_notifier_handler(void *arg)
+{
+ static char buf[8];
+ procbridge p = (procbridge) arg;
+
+ syscall(SYS_read, p->notifier[1], buf, sizeof(buf));
+ return 1;
+}
+
+void procbridge_wakeup_nal(procbridge p)
+{
+ static char buf[8];
+ syscall(SYS_write, p->notifier[0], buf, sizeof(buf));
+}
+
/* Function: forward
* Arguments: nal_t *nal: pointer to my top-side nal structure
* id: the command to pass to the lower layer
procbridge p=(procbridge)b->local;
p->nal_flags |= NAL_FLAG_STOPPING;
+ procbridge_wakeup_nal(p);
do {
pthread_mutex_lock(&p->mutex);
p->nal_flags = 0;
pthread_mutex_init(&p->nal_cb_lock, 0);
+ /* initialize notifier */
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, p->notifier)) {
+ perror("socketpair failed");
+ return NULL;
+ }
+
+ if (!register_io_handler(p->notifier[1], READ_HANDLER,
+ procbridge_notifier_handler, p)) {
+ perror("fail to register notifier handler");
+ return NULL;
+ }
+
+ /* create nal thread */
if (pthread_create(&p->t, NULL, nal_thread, &args)) {
perror("nal_init: pthread_create");
return(NULL);
pthread_cond_t cond;
pthread_mutex_t mutex;
+ /* socket pair used to notify nal thread */
+ int notifier[2];
+
int nal_flags;
pthread_mutex_t nal_cb_lock;
ptl_pt_index_t ptl_size,
ptl_ac_index_t acl_size,
ptl_pid_t requested_pid);
+extern void procbridge_wakeup_nal(procbridge p);
#endif
if (!(c=force_tcp_connection((manager)b->lower,
PNAL_IP(nid,b),
- PNAL_PORT(nid,pid))))
+ PNAL_PORT(nid,pid),
+ b->local)))
return(1);
#if 0
if (!(c=force_tcp_connection((manager)b->lower,
PNAL_IP(nid,b),
- PNAL_PORT(nid,pid))))
+ PNAL_PORT(nid,pid),
+ b->local)))
return(1);
#if 0
* This file is part of Portals, http://www.sf.net/projects/sandiaportals/
*/
+#ifndef TCPNAL_PROCBRIDGE_H
+#define TCPNAL_PROCBRIDGE_H
+
#include <portals/lib-p30.h>
typedef struct bridge {
typedef int (*nal_initialize)(bridge);
extern nal_initialize nal_table[PTL_IFACE_MAX];
+
+#endif
*/
connection force_tcp_connection(manager m,
unsigned int ip,
- unsigned short port)
+ unsigned short port,
+ procbridge pb)
{
connection conn;
struct sockaddr_in addr;
exit(-1);
conn = allocate_connection(m, ip, port, fd);
+
+ /* let nal thread know this event right away */
+ if (conn)
+ procbridge_wakeup_nal(pb);
}
pthread_mutex_unlock(&m->conn_lock);
*/
#include <table.h>
+#include <procbridge.h>
typedef struct manager {
table connections;
manager m;
} *connection;
-connection force_tcp_connection(manager m, unsigned int ip, unsigned int short);
+connection force_tcp_connection(manager m, unsigned int ip, unsigned int short,
+ procbridge pb);
manager init_connections(unsigned short, int (*f)(void *, void *), void *);
void remove_connection(void *arg);
void shutdown_connections(manager m);
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#ifndef __CYGWIN__
+#include <syscall.h>
+#endif
+#include <sys/socket.h>
#include <procbridge.h>
#include <pqtimer.h>
#include <dispatch.h>
#include <errno.h>
+/* XXX CFS workaround, to give a chance to let nal thread wake up
+ * from waiting in select
+ */
+static int procbridge_notifier_handler(void *arg)
+{
+ static char buf[8];
+ procbridge p = (procbridge) arg;
+
+ syscall(SYS_read, p->notifier[1], buf, sizeof(buf));
+ return 1;
+}
+
+void procbridge_wakeup_nal(procbridge p)
+{
+ static char buf[8];
+ syscall(SYS_write, p->notifier[0], buf, sizeof(buf));
+}
+
/* Function: forward
* Arguments: nal_t *nal: pointer to my top-side nal structure
* id: the command to pass to the lower layer
procbridge p=(procbridge)b->local;
p->nal_flags |= NAL_FLAG_STOPPING;
+ procbridge_wakeup_nal(p);
do {
pthread_mutex_lock(&p->mutex);
p->nal_flags = 0;
pthread_mutex_init(&p->nal_cb_lock, 0);
+ /* initialize notifier */
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, p->notifier)) {
+ perror("socketpair failed");
+ return NULL;
+ }
+
+ if (!register_io_handler(p->notifier[1], READ_HANDLER,
+ procbridge_notifier_handler, p)) {
+ perror("fail to register notifier handler");
+ return NULL;
+ }
+
+ /* create nal thread */
if (pthread_create(&p->t, NULL, nal_thread, &args)) {
perror("nal_init: pthread_create");
return(NULL);
pthread_cond_t cond;
pthread_mutex_t mutex;
+ /* socket pair used to notify nal thread */
+ int notifier[2];
+
int nal_flags;
pthread_mutex_t nal_cb_lock;
ptl_pt_index_t ptl_size,
ptl_ac_index_t acl_size,
ptl_pid_t requested_pid);
+extern void procbridge_wakeup_nal(procbridge p);
#endif
if (!(c=force_tcp_connection((manager)b->lower,
PNAL_IP(nid,b),
- PNAL_PORT(nid,pid))))
+ PNAL_PORT(nid,pid),
+ b->local)))
return(1);
#if 0