-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/lua plugin #577
Open
nfranzmeier
wants to merge
10
commits into
SIPp:master
Choose a base branch
from
sky-vc-networks:feat/lua-plugin
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/lua plugin #577
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a) a plugin which can be built via make myapp which adds the ability to run lua scripts in a thread using exec command luarunthread@function_name arg1 arg2 arg3 etc. and then return a retkey which holds the key to shared memory which can read another variable msgDone to see if the memory has been updated with the results from the thread. example: <exec command="luathread@my_function calling [$5] called [$2] /> <log message="retkey [$retkey] calling = [$calling] called = [$called] /> !-- Do a loop looking for the data to be done --> <label id="start_of_loop"/> <pause milliseconds="100" /> <!-- retrieve our variables back from our previous read --> <nop> <action> <log message="luaread@[$retkey] 0" /> <exec command="luaread@[$retkey] 0" /> <strcmp assign_to="result" variable="msgDone" value="0" /> <log message="result for msgDone check = [$msgDone]"/> </action> </nop> <!-- When we're done processing jump to finished else keep looping --> <nop next="finished" test="result"/> <!-- Increment the counter and continue looping up to 10 times--> <nop> <action> <add assign_to="counter" value="1"/> <test assign_to="flag_limit" variable="counter" compare="greater_than_equal" value="100"/> <log message="flag_limit=([$flag_limit])" /> </action> </nop> <nop next="finished" test="flag_limit" /> <nop next="start_of_loop"/> <label id="finished" /> <nop> <action> <!-- Delete the shared memory because we're done --> <log message="finished!" /> <log message="luaread@[$retkey] 1" /> <exec command="luaread@[$retkey] 1" /> </action> </nop> b) The ability to do rpc calls 2. Fixed memory leak associated with having AUTO RESPONSE on - leaked during OPTIONS messages
2. This pass has the plugin working
2. Moved the custom functionality for lua scripting, rpc calls and argument processing into a plugin 3. Added some code to cause sipp to include the lualib if the USE_LUA=1 flag is set when doing the CMAKE - this is so the lua environment can be accessible to lua scripts running in the plugin
2. Added a README for some brief instructions
… affect any threads started in the plugin 2. Changes some fprintf stderr's to ERROR messages in myapp.cpp
…s so sipp can be customized more 2. Added an example to match the rpc code in myapp.cpp so rpc commands can be exercised from the command line to get call stats and set logging options
I love the idea. Could you please rebase this PR on top of current master so we can proceed? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This feature expands on the SIPP plugin capability so we can run lua scripts from inside SIPP and add/change/delete SIPP variables to be used the XML scripts, adds the ability to add new command line options, adds the capability to use rpc calls to get stats and fixes a memory leak. This was all based on the 3.6 branch.
Here's a summary
example: <exec command="luathread@my_function calling [$5] called [$2] />
<log message="retkey [$retkey] calling = [$calling] called = [$called] />
!-- Do a loop looking for the data to be done -->
When the luaread is complete, the values created in the lua script will be available to the running SIPP script for use in the XML.
Here is an example of how it will be called: note the -plugin and -lua_file options as well as the -pid_file option.
sipp -plugin libmyapp.so -lua_file sipp_sa.lua -pid_file /var/run/sipp_pg.pid -aa -ringbuffer_files 1000 -ringbuffer_size 50000000 -trace_msg -trace_logs -trace_err -message_file /var/log/sipp/sipp_message_sa.log -message_overwrite false -error_file /var/log/sipp/sipp_error_sa.log -error_overwrite false -calldebug_file /var/log/sipp/log/sipp_debug_sa.log -calldebug_overwrite false -log_file /var/log/sipp/sipp_sa.log -log_overwrite false -m 1000000 -l 1 -i 172.20.2.35 -p 5060 -s 8665988936 -nd -sf ./sa.xml 172.29.31.14
Note that the dlsym "init" has also been expanded to pass in the dlsym handle and the command line args and count so it can also process arguments. The init dlsym command in our example is used to populate an internal table with various API function pointers which contains the new commands luarun - which will fork/exec a lua script, luathread which will run a lua script in a thread and then the results can be obtained using "luaread" as in the XML example above (by polling). See the appDllLoad() function in myapp.cpp.
Another dlsym command was added to allow overriding the automatic handling of messages like OPTIONS in case you want to add SIP headers etc. to those responses.
Added the ability to do rpc calls so that various call stats can be retrieved by other programs or even from the command line using a rpc client program included in the examples directory - sa_ctl.
For example: sa_ctl get_callcount will retrieve the call counts
Fixed memory leak associated with having AUTO RESPONSE on - leaked during OPTIONS messages