[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet-nim] 16/61: disconnect after connecting (shuts down
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet-nim] 16/61: disconnect after connecting (shuts down the application) |
Date: |
Sat, 13 Apr 2019 13:35:51 +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 21c94666ae031d6cf4e7afbd16ac31e2ad0aa2d3
Author: lurchi <address@hidden>
AuthorDate: Sun Jul 29 18:28:08 2018 +0200
disconnect after connecting (shuts down the application)
---
asynccadet.nim | 16 +++++++++++-----
gnunet_application.nim | 1 -
gnunet_nim.nim | 6 ++++--
3 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/asynccadet.nim b/asynccadet.nim
index 93ad2fd..171382a 100644
--- a/asynccadet.nim
+++ b/asynccadet.nim
@@ -82,11 +82,6 @@ proc sendMessage*(channel: CadetChannel, payload: seq[byte])
=
GNUNET_MESSAGE_TYPE_CADET_CLI)
GNUNET_MQ_send(GNUNET_CADET_get_mq(channel.handle), envelope)
-proc connectCadet*(app: ref GnunetApplication): Future[CadetHandle] =
- result = newFuture[CadetHandle]("connectCadet")
- app.connectFutures.add("cadet", result)
- discard GNUNET_SCHEDULER_add_now(cadetConnectCb, addr app[])
-
proc openPort*(handle: var CadetHandle, port: string): ref CadetPort =
var handlers = messageHandlers()
var port = hashString(port)
@@ -126,3 +121,14 @@ proc createChannel*(handle: CadetHandle, peer: string,
port: string): CadetChann
channelDisconnectCb,
addr handlers[0])
+proc connectCadet*(app: ref GnunetApplication): Future[CadetHandle] =
+ result = newFuture[CadetHandle]("connectCadet")
+ app.connectFutures.add("cadet", result)
+ discard GNUNET_SCHEDULER_add_now(cadetConnectCb, addr app[])
+
+proc disconnect*(handle: var CadetHandle) =
+ for port in handle.openPorts:
+ handle.closePort(port)
+ GNUNET_CADET_disconnect(handle.handle)
+
+
diff --git a/gnunet_application.nim b/gnunet_application.nim
index 2af100a..5f0fa0b 100644
--- a/gnunet_application.nim
+++ b/gnunet_application.nim
@@ -82,7 +82,6 @@ proc microsecondsUntilTimeout*(app: ref GnunetApplication):
int =
## get the duration until timeout in microseconds
let now = GNUNET_TIME_absolute_get()
if app.timeoutUs < now.abs_value_us:
- debug("app.timeoutUs = ", app.timeoutUs, ", now = ", now.abs_value_us)
return 0
elif app.timeoutUs == 0xff_ff_ff_ff_ff_ff_ff_ff'u64: # high(uint64) not
implemented
return -1
diff --git a/gnunet_nim.nim b/gnunet_nim.nim
index c9b0e14..b4c17b5 100644
--- a/gnunet_nim.nim
+++ b/gnunet_nim.nim
@@ -4,8 +4,10 @@ import asynccadet
proc firstTask(gnunetApp: ref GnunetApplication) {.async.} =
echo "connecting Cadet"
- let cadet = await gnunetApp.connectCadet()
- echo "hello"
+ var cadet = await gnunetApp.connectCadet()
+ echo "connected"
+ cadet.disconnect()
+ echo "disconnected"
proc main() =
var gnunetApp = initGnunetApplication("gnunet.conf")
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet-nim] 15/61: use the bundled gnunet.conf, (continued)
- [GNUnet-SVN] [gnunet-nim] 15/61: use the bundled gnunet.conf, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 20/61: let's try out ports and channels, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 11/61: make cadetConnect an async proc, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 39/61: add shutdown procedure, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 30/61: gitignore: add gnunet generated files and folders, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 27/61: cli option: add option to specify gnunet config, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 14/61: don't use AsyncEvent but store Futures in GnunetApplication, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 22/61: we get notified about an incoming CADET channel (and then we crash), gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 24/61: command line parsing; application code for creating channel, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 17/61: Merge branch 'master' of ssh://gnunet.org/gnunet-nim, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 16/61: disconnect after connecting (shuts down the application),
gnunet <=
- [GNUnet-SVN] [gnunet-nim] 12/61: fix segfaults using heap allocation, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 08/61: Merge branch 'master' of ssh://gnunet.org/gnunet-nim, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 18/61: make the cleanup proc the finalizer (no explicit call necessary anymore), gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 35/61: use nicer new syntax, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 31/61: use ref object where we only use heap allocation, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 29/61: fix crashes, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 38/61: comment: explain why we're reading from stdin in a nasty way, gnunet, 2019/04/13
- [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