fixed segfault
parent
46cad71e4b
commit
df269e4423
|
@ -125,18 +125,6 @@ class IPC::Context
|
||||||
IPC::Message.new pointerof(message)
|
IPC::Message.new pointerof(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def close
|
|
||||||
return if @closed
|
|
||||||
|
|
||||||
r = LibIPC.ipc_close(self.pointer)
|
|
||||||
if r.error_code != 0
|
|
||||||
m = String.new r.error_message.to_slice
|
|
||||||
raise Exception.new "cannot correctly close the connection: #{m}"
|
|
||||||
end
|
|
||||||
|
|
||||||
@closed = true
|
|
||||||
end
|
|
||||||
|
|
||||||
# sanitizer
|
# sanitizer
|
||||||
def pointer
|
def pointer
|
||||||
pointerof(@context)
|
pointerof(@context)
|
||||||
|
@ -149,7 +137,11 @@ class IPC::Context
|
||||||
|
|
||||||
def close
|
def close
|
||||||
return if @closed
|
return if @closed
|
||||||
LibIPC.ipc_close_all(self.pointer)
|
r = LibIPC.ipc_close_all(self.pointer)
|
||||||
|
if r.error_code != 0
|
||||||
|
m = String.new r.error_message.to_slice
|
||||||
|
raise Exception.new "cannot correctly close the connection: #{m}"
|
||||||
|
end
|
||||||
@closed = true
|
@closed = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -94,11 +94,14 @@ lib LibIPC
|
||||||
# Context is allocated, ipcd is requested and the connection/initialisation is performed.
|
# Context is allocated, ipcd is requested and the connection/initialisation is performed.
|
||||||
fun ipc_server_init(ctx : Ctx*, sname : LibC::Char*) : IPCError
|
fun ipc_server_init(ctx : Ctx*, sname : LibC::Char*) : IPCError
|
||||||
fun ipc_connection(Ctx*, LibC::Char*) : IPCError
|
fun ipc_connection(Ctx*, LibC::Char*) : IPCError
|
||||||
fun ipc_connection_switched(Ctx*, LibC::Char*) : IPCError
|
fun ipc_connection_switched(Ctx*, LibC::Char*, LibC::Int, Pointer(LibC::Int)) : IPCError
|
||||||
|
|
||||||
|
# ipc_message_copy: pm, @fd, @mtype, @utype, @payload
|
||||||
|
fun ipc_message_copy(Message*, LibC::Int, UInt8, UInt8, LibC::Char*, Int32)
|
||||||
|
|
||||||
# Closing connections.
|
# Closing connections.
|
||||||
fun ipc_close(ctx : Ctx*, index : LibC::UInt64T) : IPCError
|
fun ipc_close(ctx : Ctx*, index : LibC::UInt64T) : IPCError
|
||||||
fun ipc_close_all(ctx : Ctx*) # Void
|
fun ipc_close_all(ctx : Ctx*) : IPCError
|
||||||
|
|
||||||
fun ipc_ctx_free(Ctx*) # Void
|
fun ipc_ctx_free(Ctx*) # Void
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,10 @@ class IPC::Message
|
||||||
IPC::Message.to_packet @utype, String.new(@payload)
|
IPC::Message.to_packet @utype, String.new(@payload)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def copy_to_message_pointer(pm : LibIPC::Message*)
|
||||||
|
LibIPC.ipc_message_copy pm, @fd, @mtype, @utype, @payload, @payload.size
|
||||||
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
"(internal) utype #{@mtype}, (user) utype #{@utype}, payload #{String.new @payload}"
|
"(internal) utype #{@mtype}, (user) utype #{@utype}, payload #{String.new @payload}"
|
||||||
end
|
end
|
||||||
|
|
Reference in New Issue