少しいじくり回した後、私は次の解決策を思いついた:
ソースファイルで、パッケージを宣言した後、適切なモジュールをコンパイル/ロードしますが、パッケージで何かを宣言する前に、次のコードを追加しました。
(defmethod sb-bsd-sockets:socket-make-stream ((socket sb-bsd-sockets:socket)
&key input output
(element-type 'character)
(buffering :full)
(external-format :default)
timeout
(auto-close t))
"Default method for SOCKET objects. An ELEMENT-TYPE of :DEFAULT
will construct a bivalent stream. Acceptable values for BUFFERING
are :FULL, :LINE and :NONE. Streams will have no TIMEOUT
by default.
The stream for SOCKET will be cached, and a second invocation of this
method will return the same stream. This may lead to oddities if this
function is invoked with inconsistent arguments \(e.g., one might request
an input stream and get an output stream in response\)."
(let ((stream
(and (slot-boundp socket 'stream) (slot-value socket 'stream))))
(unless stream
(setf stream (sb-sys:make-fd-stream
(sb-bsd-sockets:socket-file-descriptor socket)
:name "a socket"
:dual-channel-p t
:input input
:output output
:element-type element-type
:buffering buffering
:external-format external-format
:timeout timeout
:auto-close auto-close)))
(setf (slot-value socket 'stream) stream)
(sb-ext:cancel-finalization socket)
stream))
sb-bsd-sockets/socket.lisp
(これは基本的に、引数リストにauto-close
キーが追加されたものからのリフトです)
このようにして、システムファイルの変更やパッチ適用を回避し、基本的にsb-bsd-socketsパッケージに直接フックします。
これまでのところ、正常に機能しているようです。の連続呼び出しによる基本的なテストで(room)
は、明らかなメモリリークはなく、パフォーマンスは期待どおりであることがわかりました。
このクラッジについてお気軽にコメントしてください。予期しない方法でシステムの安定性に影響を与える可能性があると思われる場合は。