fixed segfault
parent
46cad71e4b
commit
df269e4423
|
@ -125,18 +125,6 @@ class IPC::Context
|
|||
IPC::Message.new pointerof(message)
|
||||
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
|
||||
def pointer
|
||||
pointerof(@context)
|
||||
|
@ -149,7 +137,11 @@ class IPC::Context
|
|||
|
||||
def close
|
||||
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
|
||||
end
|
||||
|
||||
|
|
|
@ -94,11 +94,14 @@ lib LibIPC
|
|||
# Context is allocated, ipcd is requested and the connection/initialisation is performed.
|
||||
fun ipc_server_init(ctx : Ctx*, sname : 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.
|
||||
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
|
||||
|
||||
|
|
|
@ -75,6 +75,10 @@ class IPC::Message
|
|||
IPC::Message.to_packet @utype, String.new(@payload)
|
||||
end
|
||||
|
||||
def copy_to_message_pointer(pm : LibIPC::Message*)
|
||||
LibIPC.ipc_message_copy pm, @fd, @mtype, @utype, @payload, @payload.size
|
||||
end
|
||||
|
||||
def to_s
|
||||
"(internal) utype #{@mtype}, (user) utype #{@utype}, payload #{String.new @payload}"
|
||||
end
|
||||
|
|
Reference in New Issue