Bug #4243: [PATCH] DRb should not forefully close connections on DRb#stop=
_service
http://redmine.ruby-lang.org/issues/show/4243

Author: Jonas Pfenniger
Status: Open, Priority: Normal
Category: lib, Target version: 1.9.2
ruby -v: 1.9.2@30363

When DRb#stop_service is called, all connections get terminated by
calling Thread.kill on them. It means that all code that is invoked troug=
h
DRb must be exception-safe. This poses the same kind of issues we have
with Kernel#timeout.

This patch changes the behavior or DRb to only kill the accepting
thread, so that no new connections are made. New queries are also
rejected. DRb#stop_service is synchronous and waits for all child-threads=

to terminate.
---
Please note that this patch is quite old, so I may have forgotten some de=
tails
of it. It was posted on rubyforge at http://rubyforge.org/tracker/?func=3D=
detail&atid=3D1698&aid=3D14438&group_id=3D426.
The new version got imported into git and applies on top of ae3666b38fd72=
3231c0bbc3c33f4603b6e0e0ef0 or svn r30363 (not sure about the patch forma=
t)

This patch can easily be back-ported to 1.8.x since drb.rb hasn't changed=
 much.

Cheers, =

  zimbatm


----------------------------------------
http://redmine.ruby-lang.org
RnJvbSBhZTM2NjZiMzhmZDcyMzIzMWMwYmJjM2MzM2Y0NjAzYjZlMGUwZWYw
IE1vbiBTZXAgMTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBKb25hcyBQZmVubmln
ZXIgPGpvbmFzQHBmZW5uaWdlci5uYW1lPgpEYXRlOiBUaHUsIDYgSmFuIDIw
MTEgMTM6NTc6NTkgKzAwMDAKU3ViamVjdDogW1BBVENIXSBEUmIgc2hvdWxk
IG5vdCBmb3JlZnVsbHkgY2xvc2UgY29ubmVjdGlvbnMgb24gRFJiI3N0b3Bf
c2VydmljZQoKV2hlbiBEUmIjc3RvcF9zZXJ2aWNlIGlzIGNhbGxlZCwgYWxs
IGNvbm5lY3Rpb25zIGdldCB0ZXJtaW5hdGVkIGJ5CmNhbGxpbmcgVGhyZWFk
LmtpbGwgb24gdGhlbS4gSXQgbWVhbnMgdGhhdCBhbGwgY29kZSB0aGF0IGlz
IGludm9rZWQgdHJvdWdoCkRSYiBtdXN0IG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