This file is indexed.

/usr/share/doc/tiarra/module-reload.txt is in tiarra 20100212+r39209-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
Tiarra モジュールのリロードに関する改善案
=========================================

(2008/05/25)

現状
----

destruct()/new($config).

破棄->再生成の間で値を渡すにはBBSを利用する必要がある.
(もしくはどこかサブパッケージとかにおいちゃう)
けれどunloadだった場合にはそれが破棄されない.
(BBSはそもそも削除がない)
 (値に undef を指定したら BBS を消すようにしました)

また, 設定変更とモジュール変更が同時に起こった場合,
モジュールの再起動はかからずに設定の変更のみで処理される.

案1
---

config_reload() メソッドの追加.
defualt: destruct() & new().

懸念点:
  設定の変更でのみ.
  モジュールの再起動時だと, destruct() は古いモジュール,
  new() は新しいモジュールという処理が行えない.

ステータス:
  とりあえず実装中.
  $mod->config_reload($old_config) を呼ぶ.
  $mod->config は既に新しい config になっている.
  モジュール再読込と設定の変更が同時の場合は:

    $mod->destruct (古いモジュール/新しい config),
    mod->new (新しいモジュール/新しい config)

案2
---

destruct(\%info) & (モジュールreload) & new($config, \%info).
$info->{reason}{load}   = $bool;
$info->{reason}{config} = $bool;
$info->{reason}{module} = $bool;
$info->{reason}{unload} = $bool;
$info->{stash} = 自由に使うえりあ.

懸念点:
  モジュールの読み込みに失敗した場合どうするか.
  関連モジュールのインスタンスは解放できるか(デストラクタコードが残ってるか)
  stashをしばらく保持?->いつ解放するか
  タイマー系インスタンス/コードの扱い.
  (Code=>sub{ $this->xxx() } 系が使えなくなる)

案3
---

BBSを用いる.
main いじらなくていいのでお手軽.

とりあえず Tools::Rreload をつくってみた.
動作確認してないからうごくかはわかんない.

 my $my_key = __PACKAGE__;

 # At destruct().
 Tools::Reload->store($my_key, $value);

 # At new().
 my $value = Tools::Reload->fetch($my_key);
 if( !$value )
 {
   # new loading.
 }else
 {
   # reloading.
 }

案4
---

思いついたらふやす.


補足:タイマー関係
-----------------

自分で保持するのも面倒なので,
モジュールに紐づけるオプションなりなんなり.
ModuleManager が $module->destruct() よんだあともまだ残ってたら捨てるとか.

とりあえず:
  ModuleManager の ->add_module_object($module, @objects) を呼んで登録,
  ->remove_module_object($module, @objects) を呼んで解除.
  weakref を使ったので, 他のモジュールにくっつけ直すとかでなければ,
  解除は必須ではないです.
  で, destruct よんだあともまだ残っていたときは
  $object->module_destruct($module) という感じでよぶ。
  $module はインスタンスまたはクラス名で, ハッシュのキーはクラス名だけど,
  ->module_destruct にくる $module がインスタンスかクラス名かはわかりません.
  Module に ->_add_object, ->_remove_object を増やして簡単に登録できるようにした.
  module_destruct を Timer, Hook, ExternalSocket, Tiarra::Socket, それから
  Tiarra::WrapMainLoop に実装した. あと何かありましたっけ.

[EOF]