[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet-nim] 37/61: disconnect from the cadet service when
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet-nim] 37/61: disconnect from the cadet service when CadetHandle is destroyed |
Date: |
Sat, 13 Apr 2019 13:36:12 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnunet-nim.
commit 09a37a459f8344444d9d73d6e816126971f713c9
Author: lurchi <address@hidden>
AuthorDate: Mon Aug 6 21:49:07 2018 +0200
disconnect from the cadet service when CadetHandle is destroyed
---
asynccadet.nim | 17 ++++++++++-------
gnunet_nim.nim | 2 +-
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/asynccadet.nim b/asynccadet.nim
index 59c28ee..47575b7 100644
--- a/asynccadet.nim
+++ b/asynccadet.nim
@@ -125,28 +125,31 @@ proc createChannel*(handle: ref CadetHandle,
unsafeAddr handlers[0])
return channel
-proc shutdownCb(cls: pointer) {.cdecl.} =
- let cadetHandle = cast[ptr CadetHandle](cls)
- echo "shutdownCb"
+proc disconnect(cadetHandle: ptr CadetHandle) =
+ if cadetHandle.handle.isNil():
+ return
for port in cadetHandle.openPorts:
- echo "closing port"
cadetHandle.internalClosePort(port)
cadetHandle.openPorts.setLen(0)
- echo "disconnecting cadet"
GNUNET_CADET_disconnect(cadetHandle.handle)
+ cadetHandle.handle = nil
+
+proc shutdownCb(cls: pointer) {.cdecl.} =
+ disconnect(cast[ptr CadetHandle](cls))
proc cadetConnectCb(cls: pointer) {.cdecl.} =
let app = cast[ptr GnunetApplication](cls)
var future: FutureBase
if app.connectFutures.take("cadet", future):
- let cadetHandle = new(CadetHandle)
+ var cadetHandle: ref CadetHandle
+ new(cadetHandle, proc(handle: ref CadetHandle) = disconnect(addr handle[]))
cadetHandle.handle = GNUNET_CADET_connect(app.configHandle)
cadetHandle.openPorts = newSeq[ref CadetPort]()
cadetHandle.shutdownTask = GNUNET_SCHEDULER_add_shutdown(shutdownCb,
addr
cadetHandle[])
Future[ref CadetHandle](future).complete(cadetHandle)
-proc connectCadet*(app: ref GnunetApplication): Future[ref CadetHandle] =
+proc initCadet*(app: ref GnunetApplication): Future[ref CadetHandle] =
result = newFuture[ref CadetHandle]("connectCadet")
app.connectFutures.add("cadet", result)
discard GNUNET_SCHEDULER_add_now(cadetConnectCb, addr app[])
diff --git a/gnunet_nim.nim b/gnunet_nim.nim
index 9088bdf..70feb28 100644
--- a/gnunet_nim.nim
+++ b/gnunet_nim.nim
@@ -10,7 +10,7 @@ proc firstTask(gnunetApp: ref GnunetApplication,
port: string,
inputFilename: string,
outputFilename: string) {.async.} =
- var cadet = await gnunetApp.connectCadet()
+ var cadet = await gnunetApp.initCadet()
var cadetChannel: ref CadetChannel
if peer.isNil() and not port.isNil():
let cadetPort = cadet.openPort(port)
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet-nim] 28/61: newline behaviour like in gnunet-cadet, (continued)
- [GNUnet-SVN] [gnunet-nim] 28/61: newline behaviour like in gnunet-cadet, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 32/61: Revert "use ref object where we only use heap allocation", gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 26/61: first try sending messages from stdin, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 40/61: fix bug (application hangs when a peer disconnects); fixes & simplifications, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 34/61: add shutdown logic (allows GNUnet to shutdown on signals), gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 46/61: groupchat.nim: fix typo in echo message, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 25/61: fix sending messages, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 43/61: Merge branch 'master' of ssh://gnunet.org/gnunet-nim, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 21/61: add GNUnet configs and scripts for testing, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 56/61: gnunet_nim.nim: fix import paths to point to parent dir, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 37/61: disconnect from the cadet service when CadetHandle is destroyed,
gnunet <=
- [GNUnet-SVN] [gnunet-nim] 53/61: restructure groupchat application, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 44/61: add peer ID string functions, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 45/61: use peer IDs as chat identifiers, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 48/61: Makefile to clean the build., gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 52/61: workaround for missing notification about disconnected cadet channels, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 09/61: fix compilation, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 60/61: Start of a nimble file, should probably drop nake later on., gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 49/61: added date and time string to output, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 10/61: fix compilation (2), gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 23/61: receiving of cadet messages possible now, gnunet, 2019/04/13