[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] Misc fixes: Don"t gripe interminably about unrecommende...
Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv29132/lib/mixminion
Modified Files:
ClientDirectory.py ClientMain.py ClientUtils.py Config.py
Main.py
Log Message:
Misc fixes: Don't gripe interminably about unrecommended servers, make
reply messages work with new pathsel logic, remove bug where
undeliverable messages would get deleteed anyway, saner client queue
cleaning, misc debugging.
Index: ClientDirectory.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientDirectory.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- ClientDirectory.py 7 Nov 2003 09:26:36 -0000 1.11
+++ ClientDirectory.py 7 Nov 2003 10:43:18 -0000 1.12
@@ -525,10 +525,7 @@
"Couldn't find any currently live descriptor with name %s"
% name)
- s = s[0]
- if not self.goodServerNicknames.has_key(s.getNickname().lower()):
- LOG.warn("Server %s is not recommended",name)
-
+ s = s[0]
return s
elif os.path.exists(os.path.expanduser(name)):
# If it's a filename, try to read it.
@@ -577,7 +574,7 @@
# Make the exit hop _not_ be None; deal with getPath brokenness.
#XXXX refactor this.
if lastHop:
- if not p or p[-1].lower()!=lastHop.lower():
+ if not p or not p[-1] or p[-1].lower()!=lastHop.lower():
p.append(lastHop)
elif p[-1] == None and not exitAddress.isReply:
p[-1] = prng.pick(plausibleExits)
@@ -689,7 +686,8 @@
return servers
- def validatePath(self, pathSpec, exitAddress, startAt=None, endAt=None):
+ def validatePath(self, pathSpec, exitAddress, startAt=None, endAt=None,
+ warnUnrecommended=1):
"""DOCDOC
takes pathspec; raises UIError or does nothing."""
if startAt is None: startAt = time.time()
@@ -732,6 +730,20 @@
elif exitAddress.isServerRelative():
raise UIError("%s exit type expects a fixed exit server.",
exitAddress.getPrettyExitType())
+
+ # Check for unrecommended servers
+ if not warnUnrecommended:
+ return
+ warned = {}
+ for e in p:
+ fixed = e.getFixedServer(self, startAt, endAt)
+ if not fixed: continue
+ lc_nickname = fixed.getNickname().lower()
+ if not self.goodServerNicknames.has_key(lc_nickname):
+ if warned.has_key(lc_nickname):
+ continue
+ warned[lc_nickname] = 1
+ LOG.warn("Server %s is not recommended",fixed.getNickname())
def checkClientVersion(self):
"""Check the current client's version against the stated version in
@@ -874,7 +886,7 @@
elif type(exitType) == types.IntType:
if not (0 <= exitType <0xFFFF):
raise UIError("Exit type 0x%04X is out of range."%exitType)
- else:
+ elif exitType is not None:
raise UIError("Unknown exit type: %r"%exitType)
self.exitType = exitType
self.exitAddress = exitAddress
Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -d -r1.127 -r1.128
--- ClientMain.py 7 Nov 2003 09:07:54 -0000 1.127
+++ ClientMain.py 7 Nov 2003 10:43:18 -0000 1.128
@@ -247,7 +247,7 @@
DOCDOC args are wrong."""
#XXXX write unit tests
- allPackets = self.generateReplyMessage(
+ allPackets = self.generateReplyPackets(
directory, address, pathSpec, message, surbList, startAt, endAt)
for routing, packets in self._sortPackets(allPackets):
@@ -300,7 +300,8 @@
address.setFragmented(0,1)
routingType, routingInfo, _ = address.getRouting()
- directory.validatePath(pathSpec, address, startAt, endAt)
+ directory.validatePath(pathSpec, address, startAt, endAt,
+ warnUnrecommended=0)
for p, (path1,path2) in zip(payloads, directory.generatePaths(
len(payloads), pathSpec, address, startAt, endAt)):
@@ -312,9 +313,9 @@
return r
- def generateReplyMessage(self, directory, address, pathSpec, message,
+ def generateReplyPackets(self, directory, address, pathSpec, message,
surbList, startAt, endAt):
- """Generate a forward message, but do not send it. Returns
+ """Generate a reply message, but do not send it. Returns
a tuple of (the message body, a ServerInfo for the first hop.)
address -- the results of a parseAddress call
@@ -324,6 +325,7 @@
surbList -- a list of SURBs to consider for the second leg of
the path. We use the first one that is neither expired nor
used, and mark it used.
+ DOCDOC
"""
#XXXX write unit tests
assert address.isReply
@@ -333,9 +335,9 @@
surbLog = self.openSURBLog() # implies lock
result = []
try:
- surbs = surbLog.findUnusedSURB(surbList, len(payloads),
+ surbs = surbLog.findUnusedSURBs(surbList, len(payloads),
verbose=1, now=startAt)
- if len(surbs) <= len(payloads):
+ if len(surbs) < len(payloads):
raise UIError("Not enough usable reply blocks found; all were used or expired.")
@@ -352,6 +354,8 @@
finally:
surbLog.close() #implies unlock
+
+ return result
def openSURBLog(self):
"""Return a new, open SURBLog object for this client; it must be closed
@@ -404,11 +408,12 @@
handles = self.queueMessages(msgList, routingInfo)
if len(msgList) > 1:
- mword = "messages"
+ mword = "packets"
else:
- mword = "message"
+ mword = "packet"
try:
+ success = 0
try:
# May raise TimeoutError
LOG.info("Connecting...")
@@ -416,6 +421,7 @@
msgList,
timeout)
LOG.info("... %s sent", mword)
+ success = 1
except:
e = sys.exc_info()
if noQueue and warnIfLost:
@@ -434,6 +440,8 @@
for h in handles:
if self.queue.packetExists(h):
self.queue.removePacket(h)
+ if handles:
+ self.queue.cleanQueue()
finally:
clientUnlock()
except MixProtocolError, e:
@@ -481,14 +489,16 @@
handles = [ h for _, h in messagesByServer[routing] ]
try:
self.sendMessages(msgs, routing, noQueue=1, warnIfLost=0)
- #XXXX006 is this part needed?
- try:
- clientLock()
- for h in handles:
- if self.queue.packetExists(h):
- self.queue.removePacket(h)
- finally:
- clientUnlock()
+## #XXXX006 is this part needed?
+## try:
+## clientLock()
+## for h in handles:
+## if self.queue.packetExists(h):
+## self.queue.removePacket(h)
+## if handles:
+## self.queue.cleanQueue()
+## finally:
+## clientUnlock()
sentSome = 1
except MixError, e:
LOG.error("Can't deliver messages to %s:%s: %s; leaving messages in queue",
@@ -845,6 +855,7 @@
except ParseError, e:
raise UIError("Error parsing %s: %s" % (fn, e))
self.surbList = surbs
+ self.exitAddress = mixminion.ClientDirectory.ExitAddress(isReply=1)
else:
assert self.exitAddress is not None
useRB = 0
@@ -1033,7 +1044,7 @@
# from stdin.
surblog = client.openSURBLog()
try:
- s = surblog.findUnusedSURB(parser.path2)
+ s = surblog.findUnusedSURBs(parser.path2)
if s is None:
raise UIError("No unused and unexpired reply blocks found.")
finally:
@@ -1209,7 +1220,7 @@
separator = "\t"
for opt,val in options:
if opt in ('-F', '--feature'):
- features.append(val)
+ features.extend(val.split(","))
elif opt in ('-c', '--cascade'):
try:
cascade = int(val)
@@ -1225,7 +1236,7 @@
showTime = 2
elif opt in ('-V', '--valid'):
validOnly = 1
- elif sep in ('-s', '--separator'):
+ elif opt in ('-s', '--separator'):
separator = val
if not features:
Index: ClientUtils.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientUtils.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ClientUtils.py 7 Nov 2003 07:31:42 -0000 1.6
+++ ClientUtils.py 7 Nov 2003 10:43:18 -0000 1.7
@@ -395,8 +395,6 @@
def removePacket(self, handle):
"""Remove the packet named with the handle 'handle'."""
self.store.removeMessage(handle)
- # XXXX006 This cleanQueue shouldn't need to happen so often!
- self.store.cleanQueue()
def inspectQueue(self, now=None):
"""Print a message describing how many messages in the queue are headed
@@ -421,27 +419,28 @@
days = floorDiv(now - oldest, 24*60*60)
if days < 1:
days = "<1"
- print "%2d messages for server at %s:%s (oldest is %s days old)"%(
+ print "%2d packets for server at %s:%s (oldest is %s days old)"%(
count, s.ip, s.port, days)
- def cleanQueue(self, maxAge, now=None):
+ def cleanQueue(self, maxAge=None, now=None):
"""Remove all messages older than maxAge seconds from this
queue."""
if now is None:
now = time.time()
- cutoff = now - maxAge
- remove = []
- self.loadMetadata()
- for h in self.getHandles():
- try:
- when = self.store.getMetadata(h)[2]
- except mixminion.Filestore.CorruptedFile:
- continue
- if when < cutoff:
- remove.append(h)
- LOG.info("Removing %s old messages from queue", len(remove))
- for h in remove:
- self.store.removeMessage(h)
+ if maxAge is not None:
+ cutoff = now - maxAge
+ remove = []
+ self.loadMetadata()
+ for h in self.getHandles():
+ try:
+ when = self.store.getMetadata(h)[2]
+ except mixminion.Filestore.CorruptedFile:
+ continue
+ if when < cutoff:
+ remove.append(h)
+ LOG.info("Removing %s old messages from queue", len(remove))
+ for h in remove:
+ self.store.removeMessage(h)
self.store.cleanQueue()
def loadMetadata(self):
Index: Config.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Config.py,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- Config.py 7 Nov 2003 09:07:54 -0000 1.63
+++ Config.py 7 Nov 2003 10:43:18 -0000 1.64
@@ -636,7 +636,7 @@
if entry.lower() == ent:
return section, entry
if goodSection:
- raise UIError("Section %s has no entry %r"%(section,ent))
+ raise UIError("Section %s has no entry %r"%(goodSection,ent))
else:
raise UIError("No such section as %s"%sec)
else:
@@ -652,8 +652,8 @@
elif len(result) > 1:
secs = [ "%s:%s"%(secname,entname) for secname,entname
in result ]
- raise UIError("%r is ambiguous. Did you mean %s?",
- name, englishSequence(secs,compound="or"))
+ raise UIError("%r is ambiguous. Did you mean %s?"%(
+ name, englishSequence(secs,compound="or")))
else:
return result[0]
Index: Main.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Main.py,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- Main.py 2 Oct 2003 21:46:23 -0000 1.59
+++ Main.py 7 Nov 2003 10:43:18 -0000 1.60
@@ -119,6 +119,7 @@
"send" : ( 'mixminion.ClientMain', 'runClient' ),
"queue" : ( 'mixminion.ClientMain', 'runClient' ),
"import-server" : ( 'mixminion.ClientMain', 'importServer' ),
+ "list-server" : ( 'mixminion.ClientMain', 'listServers' ),
"list-servers" : ( 'mixminion.ClientMain', 'listServers' ),
"update-servers" : ( 'mixminion.ClientMain', 'updateServers' ),
"decode" : ( 'mixminion.ClientMain', 'clientDecode' ),