def sender_loop
loop {
begin
entry = @sending_queue.shift
if entry then
dputs ": -Queue[#{@sending_queue.size}] : #{entry.sid}"
entry.exec(@socket)
dputs ": sent a message : #{entry.sid}"
end
rescue => evar
mes = evar.message
dputs "[senderloop] #{evar.to_s} "
if mes["abort"] then
dputs ": [sendloop] disconnected by remote host."
elsif evar.class == IOError then
dputs evar.backtrace.join("\n")
dputs ": [sendloop] try to reset the connection."
@socket_lock.synchronize do
@socket_state = :socket_closing
end
else
dputs evar.backtrace.join("\n")
dputs ": [sendloop] going to recover the communication."
end
if entry then
@receiving_table[entry.sid].push ResultErrObject.new(entry.sid,R_PROTOCOL_ERROR,"IOError",evar.message,evar.backtrace.join("\n"))
end
ensure
dputs ": [sendloop]--------------"
end
@socket_lock.synchronize do
if @socket_state == :socket_closing then
dputs ": sender-thread terminating..."
return
end
end
}
end