User Tools

Site Tools


Sidebar

Table Of Contents

endurox:v7.5.x:api:xatmi:ndrx_lcf_publish.3

ndrx_lcf_publish

Name

ndrx_lcf_publish — Publish LCF command to shared memory

Synopsis

#include <lcf.h>

#include <nerror.h>

int ndrx_lcf_publish(int slot, ndrx_lcf_command_t *cmd);

Link with -lnstd -lpthread -lrt -lm

DESCRIPTION

This function is alternative of use of "$ xadmin lcf COMMAND", which is recommended way of administrating LCF commands. ndrx_lcf_publish() receives slot number in slot argument. The initialized command data is received in cmd. The Function performs validation of cmd and slot.

ndrx_lcf_command_t structure is declared as:

typedef struct
{
    int    version;
    unsigned  cmdversion;
    char cmdstr[NDRX_LCF_ADMINCMD_MAX+1];
    ndrx_stopwatch_t publtim;
    int    command;
    char   arg_a[PATH_MAX+1];
    char   arg_b[NAME_MAX+1];
    long   flags;
    char   procid[NAME_MAX];
    int    applied;
    int    failed;
    int    seen;
    long   fbackcode;
    char   fbackmsg[NDRX_LCF_FEEDBACK_BUF];

} ndrx_lcf_command_t;

Where ndrx_lcf_command_t fields is filled in following way:

version - Version number which structure was posted.

cmdversion - ignored for input (internal counter used).

cmdstr - Command string being published. This is for reference only. Max string length is 32+1.

publtim - ignored for input.

command - Command code published. Function does not verify the actually is command exists, as targeted binaries which do not have the callback for the command, will ignore the command.

arg_a - Argument -A value for the command.

arg_b - Argument -B value for the command.

flags - Any NDRX_LCF_FLAG flags. Except NDRX_LCF_FLAG_FBACK_CODE or NDRX_LCF_FLAG_FBACK_MSG. see bellow.

procid - Pid if flags contains NDRX_LCF_FLAG_PID (posting by pid) or Process name if flags contains NDRX_LCF_FLAG_BIN (posting by binary name). In regexp mode NDRX_LCF_FLAG_DOREX contains regexp expression.

applied - Must be set to 0.

failed - Must be set to 0.

seen - Must be set to 0.

fbackcode - Must contain 0.

fbackmsg - Must be empty string i.e. first byte 0x00.

FLAGS

NDRX_LCF_FLAG_PID - cmd→procid contains PID or PID regexp.

NDRX_LCF_FLAG_BIN - cmd→procid contains binary name or regexp.

NDRX_LCF_FLAG_ALL - Apply command to all binaries in application instance, same as if xadmin lcf COMMAND -a flags would be set command.

NDRX_LCF_FLAG_ARGA - Argument -A is set.

NDRX_LCF_FLAG_ARGB - Argument -B is set.

NDRX_LCF_FLAG_DOSTARTUP - Perform the command at startup of the executable which attaches to existing shared memory segments. This is the same as if xadmin lcf COMMAND -n flag would be set.

NDRX_LCF_FLAG_DOSTARTUPEXP - Perform the command at startup of the executable which attaches to existing shared memory segments, only when command age is less than NDRX_LCFCMDEXP (default is 60 seconds). This is the same as if xadmin lcf COMMAND -e flag would be set.

NDRX_LCF_FLAG_DOREX - cmd→procid contains regular expression of pid or binary name.

RETURN VALUE

On success, ndrx_lcf_publish() returns 0. On error, -1 is returned, with Nerror set to indicate the error.

ERRORS

Note that Nstrerror() returns generic error message plus custom message with debug info from last function call.

NEINVAL cmd is NULL. Invalid flags passed. Feedback fields are not reset to 0/empty. cmd→cmdstr is empty. String fields longer than field size (cmdstr, arg_a, arg_b, procid, fbackmsg). Field cmd→applied and/or cmd→failed and/or cmd→seen is not set to 0. slot value less than 0.

NEVERSION Invalid version specified in structure.

NESUPPORT LCF framework is not initialized.

NELIMIT Slot number in slot number is greater than available number of slots defined by NDRX_LCFMAX env variable (see ex_env(5)).

NESYSTEM Failed to lock semaphore for write.

NEMALLOC Malloc failed.

THREAD SAFETY

ndrx_lcf_publish() function is thread safe.

EXAMPLE

See xadmin/cmd_lcf.c for sample code.

BUGS

Report bugs to support@mavimax.com

COPYING

© Mavimax, Ltd