/* snsRtpHook.c - Socket Name Service hook for RTP deletion */ /* * Copyright (c) 2004-2007, 2009, 2011, 2013 Wind River Systems, Inc. * * The right to copy, distribute, modify or otherwise make use * of this software may be licensed only pursuant to the terms * of an applicable Wind River license agreement. */ /* modification history -------------------- 01g,16sep13,f_f fix static overrun (WIND00435182) 01f,19jul11,shi LP64 conversion 01e,03dec09,cww Moved rtp funcbind pointers 01d,20jun07,ebh remove unnecessary variable taskId in snsRtpHookInit 01c,08mar06,ebh correct typo as per code review 01b,12jan05,bwa added check for presence of RTP hooks (SPR105673). 01a,02sep04,ymz created (moved from snsLib.c) */ /* DESCRIPTION This file contains routines to invoke socket name service (SNS) to cleanup service records when the RTP where the service resides is deleted. During the SNS initialization, SNS adds a routine to the RTP delete hook. The initialization process preallocates a socket used by SNS to receive RTP delete events. When a RTP is deleted, the SNS hook is invoked. The routine sends an asynchronous message to the SNS server asking for cleanup. The routines in this file runs in the kernel, no matter whether the SNS server is running in the kernel or in a RTP. \NOMANUAL */ /* includes */ #include #include #include #include #include #include #include #include /* locals */ LOCAL int snsCleanUpSockFd; /* socket to sns server to request cleanup */ /* forward declarations */ LOCAL void snsCleanupRtnInit (void); LOCAL void snsCleanupHook (const RTP_ID rtpId, const int exitCode); /******************************************************************************* * * snsRtpHookInit - initialize the cleanup mechanism * * This function initializes the cleanup mechanism. A task is spawned so the * vxWorks system initialization process does not get delayed. * * RETURNS: OK if initialization completes, ERROR otherwise. * * \NOMANUAL */ STATUS snsRtpHookInit ( int pri /* task priority */ ) { if (_func_rtpDeleteHookAdd == NULL) { printf ("Can't initialize SNS cleanup subsystem.\n" "RTP hooks not present in the system.\n"); return (ERROR); } if((taskSpawn ("tSnsCleanupInit", pri, /* priority */ 0, /* task options */ 20000, /* stack space */ (FUNCPTR) snsCleanupRtnInit, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )) == TASK_ID_ERROR) { printf(" Cannot spawn SNS cleanup init task...\n"); return ERROR; } return OK; } /******************************************************************************* * * snsCleanupRtnInit - initializes SNS cleanup hook * * This routine initializes SNS cleanup mechanism by setting up RTP * deletion hook and attaching a connection to the SNS server. * * RETURNS: OK if the initialization is successful, ERROR otherwise. * * \NOMANUAL */ LOCAL void snsCleanupRtnInit (void) { int i; /* number of attempts attaching to SNS server */ if ( _func_rtpHandleIdGet == NULL) { printf(" SNS cleanup init failed...\n"); return; } for (i=0; i