Skip to content

Commit 9e4b6d9

Browse files
authored
use new ZMQ api (JuliaLang#729)
* use new ZMQ api * require ZMQ 1.0
1 parent e946901 commit 9e4b6d9

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
julia 0.7
22
MbedTLS 0.4.3
33
JSON 0.17
4-
ZMQ 0.6.0
4+
ZMQ 1.0.0
55
Compat 0.69.0
66
Conda 0.1.5
77
SoftGlobalScope

src/heartbeat.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ end
1818
function start_heartbeat(sock)
1919
heartbeat_c = @cfunction(heartbeat_thread, Cvoid, (Ptr{Cvoid},))
2020
ccall(:uv_thread_create, Cint, (Ptr{Int}, Ptr{Cvoid}, Ptr{Cvoid}),
21-
threadid, heartbeat_c, sock.data)
21+
threadid, heartbeat_c, sock)
2222
end

src/init.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ function __init__()
2121
end
2222

2323
# the following constants need to be initialized in init().
24-
const ctx = Ref{Context}()
2524
const publish = Ref{Socket}()
2625
const raw_input = Ref{Socket}()
2726
const requests = Ref{Socket}()
@@ -91,12 +90,11 @@ function init(args)
9190
profile["key"])
9291
end
9392

94-
ctx[] = Context()
95-
publish[] = Socket(ctx[], PUB)
96-
raw_input[] = Socket(ctx[], ROUTER)
97-
requests[] = Socket(ctx[], ROUTER)
98-
control[] = Socket(ctx[], ROUTER)
99-
heartbeat[] = Socket(ctx[], ROUTER)
93+
publish[] = Socket(PUB)
94+
raw_input[] = Socket(ROUTER)
95+
requests[] = Socket(ROUTER)
96+
control[] = Socket(ROUTER)
97+
heartbeat[] = Socket(ROUTER)
10098
bind(publish[], "$(profile["transport"])://$(profile["ip"]):$(profile["iopub_port"])")
10199
bind(requests[], "$(profile["transport"])://$(profile["ip"]):$(profile["shell_port"])")
102100
bind(control[], "$(profile["transport"])://$(profile["ip"]):$(profile["control_port"])")

src/msg.jl

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ function send_ipython(socket, m::Msg)
4545
try
4646
@vprintln("SENDING ", m)
4747
for i in m.idents
48-
send(socket, i, SNDMORE)
48+
send(socket, i, more=true)
4949
end
50-
send(socket, "<IDS|MSG>", SNDMORE)
50+
send(socket, "<IDS|MSG>", more=true)
5151
header = json(m.header)
5252
parent_header = json(m.parent_header)
5353
metadata = json(m.metadata)
5454
content = json(m.content)
55-
send(socket, hmac(header, parent_header, metadata, content), SNDMORE)
56-
send(socket, header, SNDMORE)
57-
send(socket, parent_header, SNDMORE)
58-
send(socket, metadata, SNDMORE)
55+
send(socket, hmac(header, parent_header, metadata, content), more=true)
56+
send(socket, header, more=true)
57+
send(socket, parent_header, more=true)
58+
send(socket, metadata, more=true)
5959
send(socket, content)
6060
finally
6161
unlock(socket_locks[socket])
@@ -65,22 +65,20 @@ end
6565
function recv_ipython(socket)
6666
lock(socket_locks[socket])
6767
try
68-
msg = recv(socket)
6968
idents = String[]
70-
s = unsafe_string(msg)
69+
s = recv(socket, String)
7170
@vprintln("got msg part $s")
7271
while s != "<IDS|MSG>"
7372
push!(idents, s)
74-
msg = recv(socket)
75-
s = unsafe_string(msg)
73+
s = recv(socket, String)
7674
@vprintln("got msg part $s")
7775
end
78-
signature = unsafe_string(recv(socket))
76+
signature = recv(socket, String)
7977
request = Dict{String,Any}()
80-
header = unsafe_string(recv(socket))
81-
parent_header = unsafe_string(recv(socket))
82-
metadata = unsafe_string(recv(socket))
83-
content = unsafe_string(recv(socket))
78+
header = recv(socket, String)
79+
parent_header = recv(socket, String)
80+
metadata = recv(socket, String)
81+
content = recv(socket, String)
8482
if signature != hmac(header, parent_header, metadata, content)
8583
error("Invalid HMAC signature") # What should we do here?
8684
end

0 commit comments

Comments
 (0)