From 90c577c06c29ee7d1614f62423552dfdea8d549e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Sun, 10 Oct 2021 11:01:29 +0000 Subject: [PATCH] Bug 26871: Flush SIP2 cache on every SIP request SIP connections tend to be long lived, weeks if not months, in the libraries I see. Basically the connection per SIP machine is initiated once when the SIP machine boots and then never closed until maintanance needs to be done. Therefore we need to reset the Koha's L1 caches on every SIP request to get the latest sysprefs and configs from the memcached cache that is shared between all the Koha programs (intranet, opac, sip, cronjobs) and is guaranteed to be up to date. To test: 0. Have kohadevbox 1. Enable IssueLog 2. In one terminal run the command "perl C4/SIP/SIPServer.pm /etc/koha/sites/kohadev/SIPconfig.xml" 3. Checkin and return a book using telnet: $ telnet localhost 6001 9300CNterm1|COterm1|CPCPL| 11YN20211010 10565320211010 105653AOCPL|AA1|AB3999900000001|ACterm1|BON|BIN| 09N20211010 10564420211010 105644APCPL|AOCPL|AB3999900000001|ACterm1|BIN| 4. Keep the telnet connection open and go to http://localhost:8081/cgi-bin/koha/tools/viewlog.pl and check that the *checkout* entry is in the circulation rules 5. 6. Disable IssueLog 7. Move back to the telnet prompt and check out and return a book again 11YN20211010 10565320211010 105653AOCPL|AA1|AB3999900000001|ACterm1|BON|BIN| 09N20211010 10564420211010 105644APCPL|AOCPL|AB3999900000001|ACterm1|BIN| 8. Go check out the circulation logs and notice a new entry was added when it shouldn't have according to the IssueLog syspref! 9. Apply patch and repeat steps to notice that the syspref is now followed correctly. Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- C4/SIP/SIPServer.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm index df52d5c9af..b4cf77f539 100644 --- a/C4/SIP/SIPServer.pm +++ b/C4/SIP/SIPServer.pm @@ -351,6 +351,9 @@ sub read_request { my $raw_length; local $/ = "\015"; + # SIP connections might be active for weeks, clear L1 cache on every request + Koha::Caches->flush_L1_caches(); + # proper SPEC: (octal) \015 = (hex) x0D = (dec) 13 = (ascii) carriage return my $buffer = ; if ( defined $buffer ) { -- 2.39.5