+++ /dev/null
-diff -urN /src/buildbot-slave-0.8.6p1.orig/buildslave/runprocess.py /src/buildbot-slave-0.8.6p1/buildslave/runprocess.py
---- buildbot-slave-0.8.6p1.orig/buildslave/runprocess.py 2012-03-26 04:09:10 +0400
-+++ buildbot-slave-0.8.6p1/buildslave/runprocess.py 2013-03-31 05:18:55 +0400
-@@ -24,6 +24,7 @@
- import re
- import subprocess
- import traceback
-+import tempfile
- import stat
- from collections import deque
-
-@@ -36,6 +37,89 @@
- if runtime.platformType == 'posix':
- from twisted.internet.process import Process
-
-+if os.name == 'nt':
-+ import win32api
-+ import win32process
-+ import win32event
-+ import pywintypes
-+
-+def safe_terminate_process (proc, code):
-+ if os.name == 'nt':
-+ log.msg ("Obtaining current process handle")
-+ cp = win32api.GetCurrentProcess ()
-+ result = False
-+ log.msg ("Expanding target process handle permissions")
-+ dupproc = win32api.DuplicateHandle (cp, proc._handle, cp, 2 | 1024 | 8 | 32 | 16 | 0x100000, 0, 0)
-+ log.msg ("Expanded.")
-+ try:
-+ log.msg ("Checking exit code of target process")
-+ exitcode = win32process.GetExitCodeProcess (dupproc)
-+ log.msg ("Exit code is %d" % exitcode)
-+ if exitcode == 0x103:
-+ log.msg ("Opening kernel32.dll")
-+ kernel32 = win32api.GetModuleHandle ("kernel32")
-+ log.msg ("Getting ExitProcess() address")
-+ exitprocess = win32api.GetProcAddress (kernel32, "ExitProcess")
-+ try:
-+ log.msg ("Creating remote thread")
-+ th = 0
-+ tid = 0
-+ failed = False
-+ th, tid = win32process.CreateRemoteThread (dupproc, None, 0, exitprocess, code, 0)
-+ log.msg ("Created remote thread %d" % tid)
-+ except pywintypes.error as e:
-+ if e[0] == 5:
-+ log.msg ("Access denied. It still might die, so don't fail yet")
-+ pass
-+ else:
-+ log.msg("exception %s - %s" % (sys.exc_info()[0], sys.exc_info()[1]))
-+ failed = True
-+ except Exception as e:
-+ log.msg("exception %s - %s" % (sys.exc_info()[0], sys.exc_info()[1]))
-+ failed = True
-+ if not failed:
-+ log.msg ("Wait for 5 seconds or until it dies (usually takes around 1 microsecond)")
-+ waitresult = win32event.WaitForSingleObject (dupproc, 5)
-+ log.msg ("Result of waiting: %d" % waitresult)
-+ win32api.CloseHandle (th)
-+ if waitresult == 0:
-+ result = True
-+ else:
-+ result = True
-+ except:
-+ log.msg("exception %s - %s" % (sys.exc_info()[0], sys.exc_info()[1]))
-+ finally:
-+ win32api.CloseHandle (dupproc)
-+ return result
-+ else:
-+ return proc.kill ()
-+
-+class Dummy(object):
-+ def SetHandle (self, h):
-+ self._handle = h
-+
-+def safe_terminate_process_by_pid (proc, code):
-+ if os.name == 'nt':
-+ try:
-+ log.msg("Opening process %d" % proc)
-+ openproc = win32api.OpenProcess (2 | 1024 | 8 | 32 | 16 | 0x100000, 0, proc)
-+ log.msg("Opened process %d" % proc)
-+ try:
-+ d = Dummy ()
-+ d.SetHandle (openproc)
-+ log.msg("Terminating it safely")
-+ safe_terminate_process (d, code)
-+ log.msg("Finished terminating")
-+ finally:
-+ log.msg("Closing process handle")
-+ win32api.CloseHandle (openproc)
-+ except:
-+ log.msg("exception %s - %s" % (sys.exc_info()[0], sys.exc_info()[1]))
-+ pass
-+ else:
-+ return os.kill (proc, code)
-+
-+
- def shell_quote(cmd_list):
- # attempt to quote cmd_list such that a shell will properly re-interpret
- # it. The pipes module is only available on UNIX, and Windows "shell"
-@@ -148,6 +232,7 @@
- self.pending_stdin = ""
- self.stdin_finished = False
- self.killed = False
-+ self.scriptfile = ""
-
- def setStdin(self, data):
- assert not self.connected
-@@ -198,6 +283,11 @@
- rc = 1
- else:
- rc = -1
-+ if self.scriptfile:
-+ try:
-+ os.remove (self.scriptfile)
-+ except:
-+ pass
- self.command.finished(sig, rc)
-
-
-@@ -408,9 +498,14 @@
-
- if type(self.command) in types.StringTypes:
- if runtime.platformType == 'win32':
-- argv = os.environ['COMSPEC'].split() # allow %COMSPEC% to have args
-- if '/c' not in argv: argv += ['/c']
-- argv += [self.command]
-+ if os.environ['BUILDSLAVE_SHELL']:
-+ argv = os.environ['BUILDSLAVE_SHELL'].split() # allow %COMSPEC% to have args
-+ argv += [self.command]
-+ else:
-+ argv = os.environ['COMSPEC'].split() # allow %COMSPEC% to have args
-+ if '/c' not in argv:
-+ argv += ['/c']
-+ argv += [self.command]
- else:
- # for posix, use /bin/sh. for other non-posix, well, doesn't
- # hurt to try
-@@ -424,9 +519,26 @@
- # handle path searching, etc.
- if runtime.platformType == 'win32' and not \
- (self.command[0].lower().endswith(".exe") and os.path.isabs(self.command[0])):
-- argv = os.environ['COMSPEC'].split() # allow %COMSPEC% to have args
-- if '/c' not in argv: argv += ['/c']
-- argv += list(self.command)
-+ if os.environ['BUILDSLAVE_SHELL']:
-+ argv = os.environ['BUILDSLAVE_SHELL'].split()
-+ # Create a temporary script file that changes current directory
-+ # and runs the command we want
-+ # It will be deleted after command is finished running (see RunProcessPP)
-+ tf, tf_name = tempfile.mkstemp ()
-+ f = os.fdopen (tf, 'wb')
-+ fcontents = '#!/bin/sh\ncd {}\n{}'.format (
-+ re.sub(r'(?<!\\) ','\\ ', self.workdir.replace('\\','/')),
-+ ' '.join (self.command))
-+ f.write (fcontents)
-+ log.msg("Script: {}".format (fcontents))
-+ f.close ()
-+ self.pp.scriptfile = tf_name
-+ argv += [tf_name.replace('\\','/')]
-+ else:
-+ argv = os.environ['COMSPEC'].split() # allow %COMSPEC% to have args
-+ if '/c' not in argv:
-+ argv += ['/c']
-+ argv += list(self.command)
- else:
- argv = self.command
- # Attempt to format this for use by a shell, although the process isn't perfect
-@@ -439,7 +551,7 @@
- self.environ['PWD'] = os.path.abspath(self.workdir)
-
- # self.stdin is handled in RunProcessPP.connectionMade
--
-+ log.msg("Running {}".format (argv))
- log.msg(" " + display)
- self._addToBuffers('header', display+"\n")
-
-@@ -770,9 +882,7 @@
- if self.interruptSignal == None:
- log.msg("self.interruptSignal==None, only pretending to kill child")
- else:
-- log.msg("using TASKKILL /F PID /T to kill pid %s" % self.process.pid)
-- subprocess.check_call("TASKKILL /F /PID %s /T" % self.process.pid)
-- log.msg("taskkill'd pid %s" % self.process.pid)
-+ safe_terminate_process_by_pid (self.process.pid, 1)
- hit = 1
-
- # try signalling the process itself (works on Windows too, sorta)
-@@ -795,10 +905,11 @@
- if not hit:
- log.msg("signalProcess/os.kill failed both times")
-
-- if runtime.platformType == "posix":
-+ if runtime.platformType == "posix" or runtime.platformType == "win32":
- # we only do this under posix because the win32eventreactor
- # blocks here until the process has terminated, while closing
- # stderr. This is weird.
-+ # LRN: Turns out, things don't work without this on W32. At all.
- self.pp.transport.loseConnection()
-
- if self.deferred:
+++ /dev/null
-Index: src/include/gnunet_constants.h
-===================================================================
---- src/include/gnunet_constants.h (revision 26030)
-+++ src/include/gnunet_constants.h (working copy)
-@@ -49,7 +49,7 @@
- * After how long do we consider a connection to a peer dead
- * if we don't receive messages from the peer?
- */
--#define GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
-+#define GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, 5)
-
- /**
- * How long do we delay reading more from a peer after a quota violation?
-@@ -61,7 +61,7 @@
- * even if we assume that the service commonly does not
- * respond instantly (DNS, Database, etc.).
- */
--#define GNUNET_CONSTANTS_SERVICE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10)
-+#define GNUNET_CONSTANTS_SERVICE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, 10)
-
- /**
- * How long do we delay messages to get larger packet sizes (CORKing)?
-Index: src/transport/gnunet-service-transport_neighbours.c
-===================================================================
---- src/transport/gnunet-service-transport_neighbours.c (revision 26030)
-+++ src/transport/gnunet-service-transport_neighbours.c (working copy)
-@@ -65,7 +65,7 @@
- * send 3 keepalives in each interval, so 3 messages would need to be
- * lost in a row for a disconnect).
- */
--#define KEEPALIVE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100)
-+#define KEEPALIVE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, 100)
-
- /**
- * How long are we willing to wait for a response from ATS before timing out?
-Index: src/transport/gnunet-service-transport_validation.c
-===================================================================
---- src/transport/gnunet-service-transport_validation.c (revision 26030)
-+++ src/transport/gnunet-service-transport_validation.c (working copy)
-@@ -43,7 +43,7 @@
- * OTOH, we don't want to spend too much time generating PONG signatures,
- * so they must have some lifetime to reduce our CPU usage.
- */
--#define PONG_SIGNATURE_LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 1)
-+#define PONG_SIGNATURE_LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 12)
-
- /**
- * After how long do we expire an address in a HELLO that we just
-@@ -58,24 +58,24 @@
- * we cannot validate (because after this time we can destroy the
- * validation record).
- */
--#define UNVALIDATED_PING_KEEPALIVE GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
-+#define UNVALIDATED_PING_KEEPALIVE GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
-
- /**
- * How often do we PING an address that we have successfully validated
- * in the past but are not actively using? Should be (significantly)
- * smaller than HELLO_ADDRESS_EXPIRATION.
- */
--#define VALIDATED_PING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
-+#define VALIDATED_PING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 6)
-
- /**
- * How often do we PING an address that we are currently using?
- */
--#define CONNECTED_PING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2)
-+#define CONNECTED_PING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, 2)
-
- /**
- * How much delay is acceptable for sending the PING or PONG?
- */
--#define ACCEPTABLE_PING_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
-+#define ACCEPTABLE_PING_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
-
- /**
- * Size of the validation map hashmap.
-@@ -745,9 +745,9 @@
- void
- GST_validation_start (unsigned int max_fds)
- {
-- validation_next = GNUNET_TIME_absolute_get();
-- validation_delay.rel_value = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value) / max_fds;
-- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Delay between validations: %u ms\n ", validation_delay.rel_value);
-+ validation_next = GNUNET_TIME_absolute_get();
-+ validation_delay.rel_value = GNUNET_TIME_UNIT_MILLISECONDS.rel_value;
-+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Delay between validations: %u ms\n ", validation_delay.rel_value);
- validation_map = GNUNET_CONTAINER_multihashmap_create (VALIDATION_MAP_SIZE,
- GNUNET_NO);
- pnc = GNUNET_PEERINFO_notify (GST_cfg, &process_peerinfo_hello, NULL);
+++ /dev/null
-Index: src/transport/gnunet-service-transport_neighbours.c
-===================================================================
---- src/transport/gnunet-service-transport_neighbours.c (revision 27335)
-+++ src/transport/gnunet-service-transport_neighbours.c (working copy)
-@@ -65,7 +65,7 @@
- * send 3 keepalives in each interval, so 3 messages would need to be
- * lost in a row for a disconnect).
- */
--#define KEEPALIVE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100)
-+#define KEEPALIVE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, 100)
-
- /**
- * How long are we willing to wait for a response from ATS before timing out?
-Index: src/transport/gnunet-service-transport_validation.c
-===================================================================
---- src/transport/gnunet-service-transport_validation.c (revision 27335)
-+++ src/transport/gnunet-service-transport_validation.c (working copy)
-@@ -42,7 +42,7 @@
- * OTOH, we don't want to spend too much time generating PONG signatures,
- * so they must have some lifetime to reduce our CPU usage.
- */
--#define PONG_SIGNATURE_LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 1)
-+#define PONG_SIGNATURE_LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 12)
-
- /**
- * After how long do we expire an address in a HELLO that we just
-@@ -57,24 +57,24 @@
- * we cannot validate (because after this time we can destroy the
- * validation record).
- */
--#define UNVALIDATED_PING_KEEPALIVE GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
-+#define UNVALIDATED_PING_KEEPALIVE GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
-
- /**
- * How often do we PING an address that we have successfully validated
- * in the past but are not actively using? Should be (significantly)
- * smaller than HELLO_ADDRESS_EXPIRATION.
- */
--#define VALIDATED_PING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
-+#define VALIDATED_PING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 6)
-
- /**
- * How often do we PING an address that we are currently using?
- */
--#define CONNECTED_PING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2)
-+#define CONNECTED_PING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, 2)
-
- /**
- * How much delay is acceptable for sending the PING or PONG?
- */
--#define ACCEPTABLE_PING_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
-+#define ACCEPTABLE_PING_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
-
- /**
- * Size of the validation map hashmap.
-Index: src/include/gnunet_constants.h
-===================================================================
---- src/include/gnunet_constants.h (revision 27335)
-+++ src/include/gnunet_constants.h (working copy)
-@@ -49,7 +49,7 @@
- * After how long do we consider a connection to a peer dead
- * if we don't receive messages from the peer?
- */
--#define GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
-+#define GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, 5)
-
- /**
- * How long do we delay reading more from a peer after a quota violation?
-@@ -61,7 +61,7 @@
- * even if we assume that the service commonly does not
- * respond instantly (DNS, Database, etc.).
- */
--#define GNUNET_CONSTANTS_SERVICE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10)
-+#define GNUNET_CONSTANTS_SERVICE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, 10)
-
- /**
- * How long do we delay messages to get larger packet sizes (CORKing)?