pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/pbulk pbulk-0.24:
details: https://anonhg.NetBSD.org/pkgsrc/rev/fc5efe369b6b
branches: trunk
changeset: 538050:fc5efe369b6b
user: joerg <joerg%pkgsrc.org@localhost>
date: Sat Jan 26 00:34:57 2008 +0000
description:
pbulk-0.24:
When all jobs are processed in master mode, close the listen socket
and shutdown(2) all peers. Give them a second to close(2) the
connection themselve, so that the port remains usable on the master.
This is the standard compliant fix for PR 37002.
diffstat:
pkgtools/pbulk/Makefile | 4 ++--
pkgtools/pbulk/files/pbulk/pbuild/master.c | 23 ++++++++++++++++++++---
pkgtools/pbulk/files/pbulk/pscan/master.c | 23 ++++++++++++++++++++---
3 files changed, 42 insertions(+), 8 deletions(-)
diffs (142 lines):
diff -r 7aa192934719 -r fc5efe369b6b pkgtools/pbulk/Makefile
--- a/pkgtools/pbulk/Makefile Sat Jan 26 00:12:01 2008 +0000
+++ b/pkgtools/pbulk/Makefile Sat Jan 26 00:34:57 2008 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.30 2008/01/21 13:11:56 tnn Exp $
+# $NetBSD: Makefile,v 1.31 2008/01/26 00:34:57 joerg Exp $
-DISTNAME= pbulk-0.23
+DISTNAME= pbulk-0.24
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
diff -r 7aa192934719 -r fc5efe369b6b pkgtools/pbulk/files/pbulk/pbuild/master.c
--- a/pkgtools/pbulk/files/pbulk/pbuild/master.c Sat Jan 26 00:12:01 2008 +0000
+++ b/pkgtools/pbulk/files/pbulk/pbuild/master.c Sat Jan 26 00:34:57 2008 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: master.c,v 1.5 2008/01/15 21:43:32 joerg Exp $ */
+/* $NetBSD: master.c,v 1.6 2008/01/26 00:34:57 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -55,6 +55,8 @@
#include "pbuild.h"
static LIST_HEAD(, build_peer) active_peers, inactive_peers, unassigned_peers;
+static struct event listen_event;
+static int listen_event_socket;
struct build_peer {
LIST_ENTRY(build_peer) peer_link;
@@ -170,6 +172,21 @@
}
static void
+shutdown_master(void)
+{
+ struct timeval tv;
+ struct build_peer *peer;
+
+ event_del(&listen_event);
+ (void)close(listen_event_socket);
+ LIST_FOREACH(peer, &inactive_peers, peer_link)
+ (void)shutdown(peer->fd, SHUT_RDWR);
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+ event_loopexit(&tv);
+}
+
+static void
assign_job(void *arg)
{
struct build_peer *peer = arg;
@@ -192,7 +209,7 @@
if (peer->job == NULL) {
LIST_INSERT_HEAD(&unassigned_peers, peer, peer_link);
if (LIST_EMPTY(&active_peers))
- event_loopexit(NULL);
+ shutdown_master();
return;
}
@@ -251,7 +268,6 @@
void
master_mode(const char *master_port, const char *start_script)
{
- struct event listen_event;
struct sockaddr_in dst;
int fd;
@@ -293,6 +309,7 @@
event_set(&listen_event, fd, EV_READ | EV_PERSIST, listen_handler, NULL);
event_add(&listen_event, NULL);
+ listen_event_socket = fd;
event_dispatch();
diff -r 7aa192934719 -r fc5efe369b6b pkgtools/pbulk/files/pbulk/pscan/master.c
--- a/pkgtools/pbulk/files/pbulk/pscan/master.c Sat Jan 26 00:12:01 2008 +0000
+++ b/pkgtools/pbulk/files/pbulk/pscan/master.c Sat Jan 26 00:34:57 2008 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: master.c,v 1.4 2007/07/21 15:36:36 tnn Exp $ */
+/* $NetBSD: master.c,v 1.5 2008/01/26 00:34:57 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -55,6 +55,8 @@
#include "pscan.h"
static LIST_HEAD(, scan_peer) active_peers, inactive_peers;
+static struct event listen_event;
+static int listen_event_socket;
struct scan_peer {
LIST_ENTRY(scan_peer) peer_link;
@@ -147,6 +149,21 @@
}
static void
+shutdown_master(void)
+{
+ struct timeval tv;
+ struct scan_peer *peer;
+
+ event_del(&listen_event);
+ (void)close(listen_event_socket);
+ LIST_FOREACH(peer, &inactive_peers, peer_link)
+ (void)shutdown(peer->fd, SHUT_RDWR);
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+ event_loopexit(&tv);
+}
+
+static void
assign_job(struct scan_peer *peer)
{
size_t job_len;
@@ -156,7 +173,7 @@
if (peer->job == NULL) {
LIST_INSERT_HEAD(&inactive_peers, peer, peer_link);
if (LIST_EMPTY(&active_peers))
- event_loopexit(NULL);
+ shutdown_master();
return;
}
@@ -201,7 +218,6 @@
void
master_mode(const char *master_port, const char *start_script)
{
- struct event listen_event;
struct sockaddr_in dst;
int fd;
@@ -242,6 +258,7 @@
event_set(&listen_event, fd, EV_READ | EV_PERSIST, listen_handler, NULL);
event_add(&listen_event, NULL);
+ listen_event_socket = fd;
event_dispatch();
Home |
Main Index |
Thread Index |
Old Index