596 lines
19 KiB
C
596 lines
19 KiB
C
/*----------------------------------------------------------------------------*/
|
|
/* File: io_hdl_tux.c */
|
|
/*----------------------------------------------------------------------------*/
|
|
/* */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* IMR - Interlinking Message Router */
|
|
/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */
|
|
/* mailto:arnaud@rx3.net */
|
|
/* http://www.rx3.org/dvp/?dvp=imr */
|
|
/*----------------------------------------------------------------------------*/
|
|
/* This file is part of IMR */
|
|
/* */
|
|
/* This program is free software; you can redistribute it and/or */
|
|
/* modify it under the terms of the GNU General Public License */
|
|
/* as published by the Free Software Foundation; either version 2 */
|
|
/* of the License, or (at your option) any later version. */
|
|
/* */
|
|
/* This program is distributed in the hope that it will be useful, */
|
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
/* GNU General Public License for more details. */
|
|
/* */
|
|
/* You should have received a copy of the GNU General Public License */
|
|
/* along with this program; if not, write to the Free Software Foundation, */
|
|
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
#define _LIBIO_MNG_
|
|
#define _IO_HDL_TUX_C_
|
|
|
|
|
|
|
|
#include "io_hdl_tux.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* IO_Hdl_Tux_Open */
|
|
/*----------------------------------------------------------------------------*/
|
|
/* Medium_Ptr: Pointer to the medium to open */
|
|
/* Medium_Path: Medium Path to open */
|
|
/* Dir_Id: Medium open direction */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
IMRT_Status IO_Hdl_Tux_Open( IMRT_Medium *Medium_Ptr, IMRT_Medium_Path Medium_Path, IMRT_Dir_Id Dir_Id)
|
|
{
|
|
char *Pos_Slash_Ptr;
|
|
|
|
|
|
Pos_Slash_Ptr = strstr(Medium_Path, "/");
|
|
|
|
if(Pos_Slash_Ptr == NULL)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Invalid tux path [%s] !", Medium_Path);
|
|
|
|
return( IMRS_KO);
|
|
}
|
|
else
|
|
{
|
|
strncpy(Medium_Ptr->Tux.Queue_Space, Medium_Path, strlen(Medium_Path) - strlen(Pos_Slash_Ptr));
|
|
Medium_Ptr->Tux.Queue_Space[strlen(Medium_Path) - strlen(Pos_Slash_Ptr)] = '\0';
|
|
|
|
strcpy(Medium_Ptr->Tux.Queue_Name, (Pos_Slash_Ptr + 1));
|
|
|
|
if( Queue_Exist( Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name) != IMRS_OK)
|
|
{
|
|
IMRD_LM_LOG_ERROR_2( "Tux Queue doesn't exist: Queue_Space: [%s] Queue: [%s] !", Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name);
|
|
return( IMRS_KO);
|
|
}
|
|
else
|
|
{
|
|
IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Queue_Space: [%s] Queue: [%s] opened !", Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name);
|
|
|
|
return( IMRS_OK);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* IO_Hdl_Tux_Close */
|
|
/*----------------------------------------------------------------------------*/
|
|
/* Medium_Ptr: Pointer to the medium to close */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
IMRT_Status IO_Hdl_Tux_Close( IMRT_Medium *Medium_Ptr)
|
|
{
|
|
IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Queue_Space: [%s] Queue: [%s] closed !", Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name);
|
|
|
|
return( IMRS_OK);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* IO_Hdl_Tux_Read */
|
|
/*----------------------------------------------------------------------------*/
|
|
/* Buffer_Ptr: Buffer to write data in */
|
|
/* Read_Len_Ptr: Number of byte writen */
|
|
/* Medium_Path: Medium to read */
|
|
/* Read_Mode: Read mode */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
IMRT_Status IO_Hdl_Tux_Read( IMRT_Buffer *Buffer_Ptr, size_t *Read_Len_Ptr, IMRT_Medium *Medium_Ptr, IMRT_Read_Mode Read_Mode)
|
|
{
|
|
IMRT_Tux_Buffer *Tux_Buffer_Ptr = NULL;
|
|
TPQCTL queue_param;
|
|
long len;
|
|
long flags;
|
|
|
|
|
|
memset(queue_param.corrid, '\0', sizeof(queue_param.corrid));
|
|
|
|
switch( Read_Mode)
|
|
{
|
|
case IMRD_READ_MODE_WAIT:
|
|
{
|
|
queue_param.flags = TPQWAIT;
|
|
break;
|
|
}
|
|
|
|
case IMRD_READ_MODE_NO_WAIT:
|
|
{
|
|
break;
|
|
}
|
|
|
|
|
|
default:
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Unknown Read_Mode: (%d) !", Read_Mode);
|
|
|
|
return( IMRS_KO);
|
|
}
|
|
}
|
|
|
|
queue_param.diagnostic = 0L;
|
|
|
|
if( ( Tux_Buffer_Ptr = (IMRT_Tux_Buffer *)tpalloc(IMRD_FML_TYPE_32, NULL, IMRD_TUX_BUFFER_SIZE)) == NULL)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Can't allocate Tux_Buffer_Ptr [%s] !", tpstrerror(tperrno));
|
|
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( Finit32( (IMRT_Tux_Buffer *)Tux_Buffer_Ptr, (FLDLEN32)IMRD_TUX_BUFFER_SIZE) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Can't initialize Tux_Buffer_Ptr [%s] !", Fstrerror32(Ferror32));
|
|
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
|
|
if( tpdequeue( Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name, &queue_param, (char **)&Tux_Buffer_Ptr, &len, TPNOTIME) == -1)
|
|
{
|
|
switch( tperrno)
|
|
{
|
|
case TPGOTSIG:
|
|
{
|
|
IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Signal received during reading from QSpace [%s] QueueName [%s] !", Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name);
|
|
|
|
return( IMRS_SIGNAL);
|
|
}
|
|
|
|
default:
|
|
{
|
|
switch( queue_param.diagnostic)
|
|
{
|
|
case QMENOMSG:
|
|
{
|
|
IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "No more data to read from QSpace [%s] QueueName [%s] !", Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name);
|
|
|
|
return( IMRS_NO_DATA);
|
|
}
|
|
|
|
default:
|
|
{
|
|
IMRD_LM_LOG_ERROR_4( "Can't read buffer from QSpace [%s] QueueName [%s] : [%s] [%d] !", Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name, tpstrerror(tperrno), queue_param.diagnostic);
|
|
|
|
return( IMRS_KO);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Buffer_Ptr->Data_Buf_Ptr = (IMRT_Buffer_Data *)Tux_Buffer_Ptr;
|
|
Buffer_Ptr->Data_Buf_Len = Fused32( Tux_Buffer_Ptr);
|
|
Buffer_Ptr->Data_Buf_Size = Fsizeof32( Tux_Buffer_Ptr);
|
|
Buffer_Ptr->Status = IMRD_BUFFER_STATUS_ALLOCATED;
|
|
|
|
*Read_Len_Ptr = Buffer_Ptr->Data_Buf_Len;
|
|
|
|
if( IMR_SDM_Fmt_Id_Get( &( Buffer_Ptr->Fmt_Id), "FML") != IMRS_OK)
|
|
{
|
|
IMRD_LM_LOG_ERROR_0( "Can't get FmtId !");
|
|
|
|
return( IMRS_KO);
|
|
}
|
|
else
|
|
{
|
|
IMRD_LM_LOG_TRACE_3( IMRD_LOG_LEVEL_VERBOSE_1, "Read (%d) bytes from Queue_Space: [%s] Queue: [%s] !", Buffer_Ptr->Data_Buf_Len, Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name);
|
|
|
|
return( IMRS_OK);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* IO_Hdl_Tux_Write */
|
|
/*----------------------------------------------------------------------------*/
|
|
/* Medium_Ptr: Pointer to the medium to write data to */
|
|
/* Write_Len_Ptr: Number of byte writen */
|
|
/* Buffer_Ptr: Buffer to read */
|
|
/* Write_Len_Ptr: Number of byte writen */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
IMRT_Status IO_Hdl_Tux_Write( IMRT_Medium *Medium_Ptr, size_t *Write_Len_Ptr, IMRT_Buffer *Buffer_Ptr)
|
|
{
|
|
TPQCTL queue_param;
|
|
|
|
memset( queue_param.corrid, '\0', sizeof( queue_param.corrid));
|
|
queue_param.flags = 0L;
|
|
queue_param.diagnostic = 0L;
|
|
|
|
if( tpenqueue( Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name, &queue_param, Buffer_Ptr->Data_Buf_Ptr, 0, TPNOFLAGS) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_3( "Can't write buffer to QSpace [%s] QueueName [%s] : [%s] !", Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name, tpstrerror(tperrno) );
|
|
|
|
|
|
return( IMRS_KO);
|
|
}
|
|
else
|
|
{
|
|
*Write_Len_Ptr = Buffer_Ptr->Data_Buf_Len;
|
|
IMRD_LM_LOG_TRACE_3( IMRD_LOG_LEVEL_VERBOSE_1, "Wrote (%d) bytes to Queue_Space: [%s] Queue: [%s]!", *Write_Len_Ptr, Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name);
|
|
|
|
return( IMRS_OK);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* Queue_Alloc */
|
|
/*----------------------------------------------------------------------------*/
|
|
/* Buf_Ptr_Ptr: Tuxedo Buffer */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
IMRT_Status Queue_Alloc( IMRT_Tux_Buffer **Buf_Ptr_Ptr)
|
|
{
|
|
if( ( *Buf_Ptr_Ptr = (IMRT_Tux_Buffer *)tpalloc( IMRD_FML_TYPE_32, NULL, IMRD_TUX_BUFFER_SIZE)) == NULL)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Can't tpalloc Buffer: [%s] !", tpstrerror( tperrno));
|
|
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( Finit32( (IMRT_Tux_Buffer *)*Buf_Ptr_Ptr, (FLDLEN32)IMRD_TUX_BUFFER_SIZE) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Can't Finit32 Buffer: [%s] !", Fstrerror32( Ferror32));
|
|
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
return( IMRS_OK);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* Queue_Free */
|
|
/*----------------------------------------------------------------------------*/
|
|
/* Buf_Ptr: Tuxedo Buffer */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
IMRT_Status Queue_Free( IMRT_Tux_Buffer *Buf_Ptr)
|
|
{
|
|
if( Buf_Ptr != NULL)
|
|
{
|
|
tpfree( (char *)Buf_Ptr);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* Queue_Exist_Mib */
|
|
/*----------------------------------------------------------------------------*/
|
|
/* Queue_Space: Queue Space Name */
|
|
/* Queue_Name: Queue Name */
|
|
/* Request_Buf_Ptr: Request Tuxedo Buffer */
|
|
/* Response_Buf_Ptr: Response Tuxedo Buffer */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
IMRT_Status Queue_Exist_Mib( IMRT_Tux_Queue_Space Queue_Space, IMRT_Tux_Queue_Name Queue_Name, IMRT_Tux_Buffer *Request_Buf_Ptr, IMRT_Tux_Buffer *Response_Buf_Ptr)
|
|
{
|
|
IMRT_Tux_Lmid lmid;
|
|
long fldid1, fldid2;
|
|
long nb_occurs = 0L;
|
|
long rlen = 0L;
|
|
IMRT_Tux_Open_Info open_info;
|
|
char *qmconfig, *appqspacename;
|
|
int i;
|
|
|
|
|
|
if( Fchg32( Request_Buf_Ptr, TA_OPERATION, 0, "GET", 0) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fchg32 TA_OPERATION: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( Fchg32( Request_Buf_Ptr, TA_CLASS, 0, "T_GROUP", 0) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fchg32 TA_CLASS: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( Fchg32( Request_Buf_Ptr, TA_TMSNAME, 0, "TMS_QM", 0) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fchg32 TA_TMSNAME: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
fldid1 = TA_OPENINFO;
|
|
if( Fchg32( Request_Buf_Ptr, TA_FILTER, 0, (char *)&fldid1, 0) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fchg32 TA_FILTER: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
fldid2 = TA_LMID;
|
|
if( Fchg32( Request_Buf_Ptr, TA_FILTER, 1, (char *)&fldid2, 0) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fchg32 TA_FILTER: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( tpcall( IMRD_TMIB_SERVICE, (void *)Request_Buf_Ptr,0, (char**)&Response_Buf_Ptr, &rlen, 0L) < 0)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Error tpcall: [%s] !", tpstrerror( tperrno));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( Fget32( Response_Buf_Ptr, TA_OCCURS, 0, (char *)&nb_occurs, NULL) == -1 )
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fget32 TA_OCCURS: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
for( i=0; i < nb_occurs; i++)
|
|
{
|
|
if( Fget32( Response_Buf_Ptr, TA_OPENINFO, i, open_info, NULL) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fget32 TA_OPENINFO: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
qmconfig = (char *)strchr(open_info, ':')+1;
|
|
appqspacename = (char *)strchr(qmconfig, ':');
|
|
appqspacename[0] = 0;
|
|
appqspacename++;
|
|
|
|
if( strcmp( appqspacename, Queue_Space) == 0)
|
|
{
|
|
i = nb_occurs;
|
|
}
|
|
}
|
|
|
|
if( Fget32( Response_Buf_Ptr, TA_LMID, 0, lmid, NULL) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fget32 TA_LMID: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( Finit32( (FBFR32 *)Request_Buf_Ptr, (FLDLEN32)IMRD_TUX_BUFFER_SIZE) == -1 )
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Finit32 Buffer1: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( Finit32( (FBFR32 *)Response_Buf_Ptr, (FLDLEN32)IMRD_TUX_BUFFER_SIZE) == -1 )
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Finit32 Buffer2: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( Fchg32( Request_Buf_Ptr, TA_OPERATION, 0, "GET", 0) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fchg32 TA_OPERATION: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( Fchg32( Request_Buf_Ptr, TA_CLASS, 0, "T_APPQ", 0) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fchg32 TA_CLASS: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( Fchg32( Request_Buf_Ptr, TA_APPQSPACENAME, 0, Queue_Space, 0) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fchg32 TA_APPQSPACENAME: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( Fchg32( Request_Buf_Ptr, TA_APPQNAME, 0, Queue_Name, 0) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fchg32 TA_APPQNAME: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( Fchg32( Request_Buf_Ptr, TA_QMCONFIG, 0, qmconfig, 0) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fchg32 TA_QMCONFIG: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( Fchg32( Request_Buf_Ptr, TA_LMID, 0, lmid, 0) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fchg32 TA_LMID: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
fldid1 = TA_APPQNAME;
|
|
if( Fchg32( Request_Buf_Ptr, TA_FILTER, 0, (char *)&fldid1, 0) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fchg32 TA_FILTER: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( tpcall( IMRD_TMIB_SERVICE, (void *)Request_Buf_Ptr, 0, (char**)&Response_Buf_Ptr, &rlen, 0L) < 0)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Error tpcall: [%s] !", tpstrerror( tperrno));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( Fget32( Response_Buf_Ptr, TA_OCCURS, 0, (char *)&nb_occurs, NULL) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Fget32 TA_OCCURS: [%s] !", Fstrerror32( Ferror32));
|
|
return( IMRS_KO);
|
|
}
|
|
|
|
if( nb_occurs != 0)
|
|
{
|
|
return( IMRS_OK);
|
|
}
|
|
else
|
|
{
|
|
return( IMRS_KO);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* IO_Hdl_Tux_Exist_Queue */
|
|
/*----------------------------------------------------------------------------*/
|
|
/* Queue_Space: Queue Space Name */
|
|
/* Queue_Name: Queue Name */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
IMRT_Status Queue_Exist( IMRT_Tux_Queue_Space Queue_Space, IMRT_Tux_Queue_Name Queue_Name)
|
|
{
|
|
IMRT_Status status;
|
|
IMRT_Tux_Buffer *Request_Buffer_Ptr, *Response_Buffer_Ptr;
|
|
|
|
|
|
if( ( status = Queue_Alloc( &Request_Buffer_Ptr)) == IMRS_OK)
|
|
{
|
|
if( ( status = Queue_Alloc( &Response_Buffer_Ptr)) == IMRS_OK)
|
|
{
|
|
status = Queue_Exist_Mib( Queue_Space, Queue_Name, Request_Buffer_Ptr, Response_Buffer_Ptr);
|
|
|
|
Queue_Free( Response_Buffer_Ptr);
|
|
}
|
|
|
|
Queue_Free( Request_Buffer_Ptr);
|
|
}
|
|
|
|
return( status);
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* IO_Hdl_Tux_Begin */
|
|
/*----------------------------------------------------------------------------*/
|
|
/* IMRT_Medium *Medium_Ptr */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
IMRT_Status IO_Hdl_Tux_Begin( IMRT_Medium *Medium_Ptr)
|
|
{
|
|
long flags ;
|
|
IMRT_Status status;
|
|
|
|
flags = 0;
|
|
status = IMRS_OK;
|
|
|
|
|
|
if(IMRG_HDL_TUX_MODE == IMRD_HDL_TUX_NOT_IN_TRANS)
|
|
{
|
|
if( tpbegin(IMRD_HDL_TUX_TIME_OUT,flags) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Tpbegin error: [%s] !", tpstrerror(tperrno));
|
|
status = IMRS_KO;
|
|
}
|
|
else
|
|
{
|
|
IMRG_HDL_TUX_MODE = IMRD_HDL_TUX_IN_TRANS;
|
|
}
|
|
}
|
|
return(status);
|
|
|
|
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* IO_Hdl_Tux_Commit */
|
|
/*----------------------------------------------------------------------------*/
|
|
/* IMRT_Medium *Medium_Ptr */
|
|
/*----------------------------------------------------------------------------*/
|
|
IMRT_Status IO_Hdl_Tux_Commit( IMRT_Medium *Medium_Ptr)
|
|
{
|
|
long flags ;
|
|
IMRT_Status status;
|
|
|
|
flags = 0;
|
|
status = IMRS_OK;
|
|
|
|
if(IMRG_HDL_TUX_MODE == IMRD_HDL_TUX_IN_TRANS)
|
|
{
|
|
if( tpcommit(flags) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Tpcommit error: [%s] !", tpstrerror(tperrno));
|
|
status = IMRS_KO;
|
|
}
|
|
else
|
|
{
|
|
IMRG_HDL_TUX_MODE = IMRD_HDL_TUX_NOT_IN_TRANS;
|
|
}
|
|
}
|
|
return(status);
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* IO_Hdl_Tux_Rollback */
|
|
/*----------------------------------------------------------------------------*/
|
|
/* IMRT_Medium *Medium_Ptr */
|
|
/*----------------------------------------------------------------------------*/
|
|
IMRT_Status IO_Hdl_Tux_Rollback( IMRT_Medium *Medium_Ptr)
|
|
{
|
|
long flags ;
|
|
IMRT_Status status;
|
|
|
|
flags = 0;
|
|
status = IMRS_OK;
|
|
|
|
if(IMRG_HDL_TUX_MODE == IMRD_HDL_TUX_IN_TRANS)
|
|
{
|
|
if( tpabort(flags) == -1)
|
|
{
|
|
IMRD_LM_LOG_ERROR_1( "Tabort error: [%s] !", tpstrerror(tperrno));
|
|
status = IMRS_KO;
|
|
}
|
|
else
|
|
{
|
|
IMRG_HDL_TUX_MODE = IMRD_HDL_TUX_NOT_IN_TRANS;
|
|
}
|
|
}
|
|
|
|
return(status);
|
|
|
|
}
|