Skip to content

Commit

Permalink
FIFO: Make the "reply FIFO filename" relatively unique in time
Browse files Browse the repository at this point in the history
This patch aims to fix rare errors such as the one below, where an
identical suffix (e.g. "_9170") gets randomly generated for two
concurrent CLI commands!

---
communication exception for 'clusterer_list_shtags' returned: cannot
create reply file /tmp/opensips_fifo_reply_9170: [Errno 17] File exists!
---
  • Loading branch information
liviuchircu committed Nov 29, 2022
1 parent a480e53 commit f6b9b4f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions opensipscli/communication/fifo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
## along with this program. If not, see <http://www.gnu.org/licenses/>.
##

import os
import stat
import errno
import os
import random
import stat
import time
from opensipscli.config import cfg
from opensipscli.logger import logger
from opensipscli.communication import jsonrpc_helper
Expand All @@ -39,7 +40,7 @@ def execute(method, params):
global fifo_file

jsoncmd = jsonrpc_helper.get_command(method, params)
reply_fifo_file_name = REPLY_FIFO_FILE_TEMPLATE.format(random.randrange(32767))
reply_fifo_file_name = REPLY_FIFO_FILE_TEMPLATE.format(time.time())
reply_dir = cfg.get('fifo_reply_dir')
reply_fifo_file = "{}/{}".format(reply_dir, reply_fifo_file_name)

Expand Down

0 comments on commit f6b9b4f

Please sign in to comment.