Skip to content
Snippets Groups Projects
Commit efbd6c8d authored by Thomas Jahns's avatar Thomas Jahns :cartwheel:
Browse files

Fix use of unfortunate filename string separator.

parent 9af5f453
No related branches found
No related tags found
No related merge requests found
......@@ -28,9 +28,6 @@ const char *const cdiPioCmdStrTab[] = {
"IO_Finalize"
};
extern const char *token;
const char *token = "%";
/***************************************************************/
void cdiPioFileWritingInit(void)
......
......@@ -44,11 +44,8 @@ fileIDTest(void *a, void *fileID)
static aFiledataM *initAFiledataMPINONB ( const char *filename, size_t bs )
{
aFiledataM *of = NULL;
int iret;
MPI_Comm commPio = commInqCommPio();
of = (aFiledataM*) Malloc(sizeof (*of) + strlen(filename) + 1);
aFiledataM *of = (aFiledataM *)Malloc(sizeof (*of) + strlen(filename) + 1);
strcpy(of->name, filename);
of->size = bs;
......@@ -56,8 +53,7 @@ static aFiledataM *initAFiledataMPINONB ( const char *filename, size_t bs )
of->db2 = NULL;
/* init output buffer */
iret = dbuffer_init ( &( of->db1 ), of->size );
int iret = dbuffer_init ( &( of->db1 ), of->size );
iret += dbuffer_init ( &( of->db2 ), of->size );
if ( iret > 0 ) xabort ( "dbuffer_init did not succeed" );
......@@ -225,10 +221,9 @@ fwMPINONB(int fileID, const void *buffer, size_t len, int tsID)
static int fcMPINONB(int fileID)
{
aFiledataM *of;
int rankPio = commInqRankPio ();
xdebug("IOPE%d: write buffer, close file and cleanup, in %d",
rankPio, fileID );
commInqRankPio(), fileID );
if (!(of = listSetGet(bibAFiledataM, fileIDTest, (void *)(intptr_t)fileID)))
xabort("listSet, fileID=%d not found", fileID);
......
......@@ -27,8 +27,6 @@
#include "pio_util.h"
#include "dmemory.h"
extern const char *token;
typedef struct
{
struct dBuffer *fb;
......@@ -256,10 +254,10 @@ void pioWriterAIO(void)
xmpi(MPI_Recv(messageBuffer, messagesize, MPI_UNSIGNED_CHAR, source,
tag, commPio, &status ));
char *filename = strtok((char *)pMB, token);
char *filename = (char *)pMB;
pMB += (strlen(filename) + 1);
char *temp = strtok((char *)pMB, token);
long buffersize = strtol(temp, NULL, 16);
char *temp = (char *)pMB;
long buffersize = strtol(temp, NULL, 16);
pMB += (strlen(temp) + 1);
size_t amount = (size_t)(messageBuffer + messagesize - pMB);
......
......@@ -16,8 +16,6 @@
#include "pio_impl.h"
#include "pio_util.h"
extern const char *token;
typedef struct
{
struct dBuffer *fb;
......@@ -127,9 +125,7 @@ pioWriterStdIO(void)
{
bFiledataP *bfd;
listSet * bibBFiledataP;
size_t amount, buffersize;
unsigned char *messageBuffer = NULL, *pMB;
char *filename, *temp;
size_t amount;
int messagesize, source, tag, id;
struct fileOpTag rtag;
MPI_Status status;
......@@ -163,47 +159,45 @@ pioWriterStdIO(void)
switch (rtag.command)
{
case IO_Open_file:
{
char *messageBuffer
= Malloc((size_t)messagesize * sizeof (messageBuffer[0]));
char *pMB = messageBuffer;
xmpi(MPI_Recv(messageBuffer, messagesize, MPI_UNSIGNED_CHAR,
source, tag, commPio, &status));
messageBuffer
= Malloc((size_t)messagesize * sizeof (messageBuffer[0]));
pMB = messageBuffer;
xmpi(MPI_Recv(messageBuffer, messagesize, MPI_UNSIGNED_CHAR,
source, tag, commPio, &status));
xdebug("%s", "after recv, in loop");
xdebug("%s", "after recv, in loop");
filename = strtok ( (char *)pMB, token );
pMB += ( strlen ( filename ) + 1 );
temp = strtok ( (char *)pMB, token );
buffersize = (size_t)strtol(temp, NULL, 16);
pMB += ( strlen ( temp ) + 1 );
amount = (size_t)(messageBuffer + messagesize - pMB);
char *filename = pMB;
pMB += (strlen(filename) + 1);
char *temp = pMB;
long buffersize = strtol(temp, NULL, 16);
pMB += (strlen(temp) + 1);
size_t amount = (size_t)(messageBuffer + messagesize - pMB);
xdebug("command %s, filename=%s, buffersize=%zu, amount=%zu",
cdiPioCmdStrTab[rtag.command], filename, buffersize, amount);
xdebug("command %s, filename=%s, buffersize=%ld, amount=%zu",
cdiPioCmdStrTab[rtag.command], filename, buffersize, amount);
if (!(bfd = listSetGet(bibBFiledataP, fileIDTest,
(void *)(intptr_t)rtag.id)))
{
listSetForeach(bibBFiledataP, elemCheck, filename);
bfd = initBFiledataP(filename, buffersize, nProcsColl,
rtag.id);
if ((id = listSetAdd(bibBFiledataP, bfd)) < 0)
xabort("fileID=%d not unique", rtag.id);
bfd->fileID = id;
}
else
if (strcmp(filename, bfd->name) != 0)
xabort("filename is not consistent, fileID=%d", rtag.id);
memcpy(bfd->fb->buffer, pMB, amount);
writeP(bfd, amount);
if (!(bfd = listSetGet(bibBFiledataP, fileIDTest,
(void *)(intptr_t)rtag.id)))
{
listSetForeach(bibBFiledataP, elemCheck, filename);
bfd = initBFiledataP(filename, (size_t)buffersize, nProcsColl,
rtag.id);
if ((id = listSetAdd(bibBFiledataP, bfd)) < 0)
xabort("fileID=%d not unique", rtag.id);
bfd->fileID = id;
}
else
if (strcmp(filename, bfd->name) != 0)
xabort("filename is not consistent, fileID=%d", rtag.id);
memcpy(bfd->fb->buffer, pMB, amount);
Free(messageBuffer);
writeP(bfd, amount);
Free(messageBuffer);
}
break;
case IO_Send_buffer:
......
......@@ -12,8 +12,6 @@
#include "pio_impl.h"
#include "pio_util.h"
extern const char *token;
typedef struct
{
size_t size;
......@@ -251,14 +249,10 @@ pioSendOpen(const char *filename, const char *mode)
filename, id);
/* put filename, id and buffersize on buffer */
iret = dbuffer_push ( afd->db, filename, strlen ( filename ));
xassert(iret == 0);
iret = dbuffer_push ( afd->db, token, 1);
iret = dbuffer_push(afd->db, filename, strlen(filename) + 1);
xassert(iret == 0);
sprintf ( message,"%lX", buffersize);
iret = dbuffer_push ( afd->db, message, strlen ( message ));
xassert(iret == 0);
iret = dbuffer_push ( afd->db, token, 1);
iret = dbuffer_push(afd->db, message, strlen(message) + 1);
xassert(iret == 0);
if ( ddebug )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment