Skip to content

Commit

Permalink
Merge pull request #66 from 1000TurquoisePogs/bugfix/dataset-buffer-a…
Browse files Browse the repository at this point in the history
…nd-logging

Removed uncessary processing & logging from standard dataset behavior
  • Loading branch information
1000TurquoisePogs authored Jul 30, 2019
2 parents 299ce73 + dbf3a20 commit adaa9c6
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 99 deletions.
126 changes: 60 additions & 66 deletions c/datasetjson.c

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions c/httpserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -3883,7 +3883,7 @@ void respondWithJsonError(HttpResponse *response, char *error, int statusCode, c
int streamBinaryForFile(Socket *socket, UnixFile *in, bool asB64) {
int returnCode = 0;
int reasonCode = 0;
int bufferSize = 3*FILE_STREAM_BUFFER_SIZE;
int bufferSize = FILE_STREAM_BUFFER_SIZE;
char buffer[bufferSize+4];
int encodedLength;

Expand Down Expand Up @@ -3918,7 +3918,7 @@ int streamTextForFile(Socket *socket, UnixFile *in, int encoding,
int returnCode = 0;
int reasonCode = 0;
int bytesSent = 0;
int bufferSize = 3*FILE_STREAM_BUFFER_SIZE;
int bufferSize = FILE_STREAM_BUFFER_SIZE;
char buffer[bufferSize+4];
char translation[(2*bufferSize)+4]; /* UTF inflation tolerance */
int encodedLength;
Expand Down
35 changes: 18 additions & 17 deletions c/jcsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "zowetypes.h"
#include "alloc.h"
#include "utils.h"

#include "logging.h"
#include "csi.h"
#include "jcsi.h"
#define _EDC_ADD_ERRNO2 1
Expand Down Expand Up @@ -67,7 +67,7 @@ csi_parmblock *process_arguments(int argc, char **argv)
if (0) {
} else if (0 == strcmp(argv[argindex], "-filter")) {
if (++argindex >= argc) {
printf("missing argument after -filter\n");
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_WARNING, "missing argument after -filter\n");
return 0;
} else {
arglen = strlen(argv[argindex]);
Expand All @@ -94,13 +94,13 @@ char *csi(csi_parmblock* csi_parms, int *workAreaSize)
*((int*)work_area) = *workAreaSize;
IGGCSI00 = (csi_fn *)fetch("IGGCSI00");
if (0 == IGGCSI00) {
printf("could not fetch IGGCSI00\n");
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_WARNING, "could not fetch IGGCSI00\n");
return 0;
}
/* print_buffer((char*)work_area,256); */
return_code = (*IGGCSI00)(&reason_code,csi_parms,work_area);
if (return_code != 0) {
printf("CSI failed ret=%d, rc=%d rchex=%x\n",return_code,reason_code,reason_code);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_WARNING, "CSI failed ret=%d, rc=%d rchex=%x\n",return_code,reason_code,reason_code);
free(work_area);
return 0;
} else {
Expand Down Expand Up @@ -149,46 +149,46 @@ int pseudoLS(char *dsn, int fieldCount, char **fieldNames){

char *entryPointer = workArea+14;
char *endPointer = workArea+workAreaUsedLength;
printf("work area length used %d\n",workAreaUsedLength);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "work area length used %d\n",workAreaUsedLength);
dumpbuffer(workArea,workAreaUsedLength);

while (entryPointer < endPointer){
EntryData *entry = (EntryData*)entryPointer;

printf("entry name %44.44s\n",entry->name);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "entry name %44.44s\n",entry->name);
dumpbuffer(entryPointer,0x60);
if (entry->flags & CSI_ENTRY_ERROR){
printf("entry has error\n");
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_WARNING, "entry has error\n");
entryPointer += sizeof(EntryData);
} else{
switch (entry->type){
case '0':
{
CSICatalogData *catalogData = (CSICatalogData*)(entry+14);
printf("catalog name %44.44s\n",catalogData->name);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "catalog name %44.44s\n",catalogData->name);
entryPointer += sizeof(CSICatalogData);
}
break;
default:
{
int fieldDataLength = entry->data.fieldInfoHeader.totalLength;
printf("entry field data length = 0x%x fieldCount=%d\n",fieldDataLength,fieldCount);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "entry field data length = 0x%x fieldCount=%d\n",fieldDataLength,fieldCount);
char *fieldData = entryPointer+sizeof(EntryData);
unsigned short *fieldLengthArray = ((unsigned short *)(entryPointer+sizeof(EntryData)));
if (entry->type == 'X'){
printf("entry is catalog alias\n");
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "entry is catalog alias\n");
} else if (entry->type == 'U'){
printf("entry is user catalog connector\n");
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "entry is user catalog connector\n");
} else{
char *fieldValueStart = entryPointer+sizeof(EntryData)+fieldCount*sizeof(short);
for (i=0; i<fieldCount; i++){
printf("field %d: %8.8s, has length %d\n",i,fieldNames[i]);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "field %d: %8.8s, has length %d\n",i,fieldNames[i]);
if (fieldLengthArray[i]){
dumpbuffer(fieldValueStart,fieldLengthArray[i]);
}
fieldValueStart += fieldLengthArray[i];
}
/* printf("volser = %6.6s\n",fieldData); */
/* zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "volser = %6.6s\n",fieldData); */
}
int advance = sizeof(EntryData)+fieldDataLength-4; /* -4 for the fact that the length is 4 from end of EntryData */
entryPointer += advance;
Expand All @@ -198,7 +198,7 @@ int pseudoLS(char *dsn, int fieldCount, char **fieldNames){
}
}
} else{
printf("no entries, no look up failure either\n");
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_WARNING, "no entries, no look up failure either\n");
}
safeFree((char*)workArea,WORK_AREA_SIZE);
return result;
Expand Down Expand Up @@ -233,6 +233,7 @@ static char *myFields[] ={ "NAME ", "LRECL ", "TYPE ","VOLSER ","VOLFLG

EntryDataSet *returnEntries(char *dsn, char *typesAllowed, int typesCount, int workAreaSize, char **fields, int fieldCount, char *resumeName, char *resumeCatalogName, csi_parmblock *returnParms){
csi_parmblock* csi_parms = returnParms;
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_INFO, "csi query for %s\n",dsn);
int dsnLen = strlen(dsn);
char *workArea = NULL;

Expand Down Expand Up @@ -285,14 +286,14 @@ EntryDataSet *returnEntries(char *dsn, char *typesAllowed, int typesCount, int w
char type = entry->type;

if (entry->flags & CSI_ENTRY_ERROR){
printf("entry has error\n");
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_WARNING, "entry has error\n");
entryPointer += sizeof(EntryData);
} else{
switch (entry->type){
case '0':
{
CSICatalogData *catalogData = (CSICatalogData*)(entry+14);
printf("catalog name %44.44s\n",catalogData->name);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "catalog name %44.44s\n",catalogData->name);
entryPointer += sizeof(CSICatalogData);
}
break;
Expand Down Expand Up @@ -332,7 +333,7 @@ EntryDataSet *returnEntries(char *dsn, char *typesAllowed, int typesCount, int w
safeFree((char*)workArea,workAreaSize);
return entrySet;
} else{
printf("no entries, no look up failure either\n");
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_WARNING, "no entries, no look up failure either\n");
}
safeFree((char*)workArea,workAreaSize);
return entrySet;
Expand Down
27 changes: 14 additions & 13 deletions c/pdsutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "zowetypes.h"
#include "alloc.h"
#include "utils.h"
#include "logging.h"
#include "pdsutil.h"

static char pdsEndName[9] ={ 0xff, 0xff, 0xff, 0xff,
Expand Down Expand Up @@ -149,7 +150,7 @@ void listDirectory(char *pdsName){

sprintf(filenameBuffer,"//'%s'",pdsName);
in = fopen(filenameBuffer,"rb");
printf("fopen in=0x%x errno=%d\n",in,errno);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "fopen in=0x%x errno=%d\n",in,errno);
while (!feof(in) && !lastBlock){
/* You should test for the last directory entry (8 bytes of
X'FF'). Records and blocks after that point are unpredictable. After
Expand All @@ -158,7 +159,7 @@ void listDirectory(char *pdsName){
int res = fread(block,1,256,in);
int posInBlock = 2;
blockCount++;
printf("PDS BLOCK %d, res=%d\n",blockCount,res);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "PDS BLOCK %d, res=%d\n",blockCount,res);
/* dumpbuffer(block,256); */
while (posInBlock < 256){
int flags = block[posInBlock+11];
Expand All @@ -170,7 +171,7 @@ void listDirectory(char *pdsName){
lastBlock = 1;
break;
}
printf("name='%8s' otherFlags = 0x%x\n",name,flags&0xe0);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "name='%8s' otherFlags = 0x%x\n",name,flags&0xe0);
dumpbuffer(block+posInBlock,blockLength);
posInBlock += blockLength;
}
Expand Down Expand Up @@ -201,9 +202,9 @@ StringList *getPDSMembers(char *pdsName){

sprintf(filenameBuffer,"//'%s'",pdsName);
in = fopen(filenameBuffer,"rb");
printf("fopen in=0x%x errno=%d\n",in);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "fopen in=0x%x errno=%d\n",in);
if (in == 0){
printf("Error encountered on reading PDS member, returning empty list\n");
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_WARNING, "Error encountered on reading PDS member, returning empty list\n");
fflush(stdout);
return list;
}
Expand All @@ -215,9 +216,9 @@ StringList *getPDSMembers(char *pdsName){
int bytesRead = fread(block,1,256,in);
int posInBlock = 2;
blockCount++;
printf("PDS BLOCK %d, bytesRead=%d\n",blockCount,bytesRead);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "PDS BLOCK %d, bytesRead=%d\n",blockCount,bytesRead);
if (bytesRead == 0){
printf("Error encountered reading PDS member, returning current list\n");
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_WARNING, "Error encountered reading PDS member, returning current list\n");
fflush(stdout);
return list;
}
Expand Down Expand Up @@ -307,13 +308,13 @@ int memberExistsInDDName(char *ddname){

memset(plist,0,GETDSAB_PLIST_LENGTH);

printf("ddname at 0x%x\n",ddname);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "ddname at 0x%x\n",ddname);
__asm(" GETDSAB DDNAME=(%2),DSABPTR=%1,LOC=ANY,RETCODE=%0,MF=(E,%3) " :
"=m"(rc), "=m"(dsab) :
"r"(ddname), "m"(plist) :
"r15");

printf("after GETDSAB rc=%d, dsab at 0x%x\n",
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "after GETDSAB rc=%d, dsab at 0x%x\n",
rc,dsab);
printf("plist:\n");
dumpbuffer(plist,16);
Expand All @@ -323,11 +324,11 @@ int memberExistsInDDName(char *ddname){
int foo = 0;
dsab = (DSAB*)((int*)dsabHandle)[0];
char *ddname2 = (char*)((int*)plist)[2];
printf("dsabHandle=0x%x ddname2=0x%x foo=0x%x\n",dsabHandle,ddname2,foo);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "dsabHandle=0x%x ddname2=0x%x foo=0x%x\n",dsabHandle,ddname2,foo);

if (rc == 0){
dumpbuffer((char*)dsabHandle,16);
printf("dsab at 0x%x\n",dsab);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "dsab at 0x%x\n",dsab);
dumpbuffer((char*)dsab,64);


Expand All @@ -342,11 +343,11 @@ int memberExistsInDDName(char *ddname){
MF=(E,WA_SWAREQ_PLIST)
*/

printf("TIOT:\n");
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "TIOT:\n");
dumpbuffer((char*)dsab->dsabtiot,64);
int tioejfcb = ((int*)dsab->dsabtiot)[3];
int jfcbSVA = (tioejfcb&0xFFFFFF00)>>8;
printf("JFCB SVA = 0x%x\n",jfcbSVA);
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "JFCB SVA = 0x%x\n",jfcbSVA);
}

return FALSE;
Expand Down
2 changes: 1 addition & 1 deletion h/httpserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

#define HTTP_SERVICE_SUCCESS 0
#define HTTP_SERVICE_FAILED 8
#define FILE_STREAM_BUFFER_SIZE 1024
#define FILE_STREAM_BUFFER_SIZE 1024000

#define HTTP_SERVER_MAX_SESSION_TOKEN_KEY_SIZE 1024u

Expand Down
2 changes: 2 additions & 0 deletions h/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ ZOWE_PRAGMA_PACK_RESET
#define LOG_COMP_DATASERVICE 0x008F0001000B0000LLU
#define LOG_COMP_CMS 0x008F0001000C0000LLU
#define LOG_COMP_LPA 0x008F0001000D0000LLU
#define LOG_COMP_RESTDATASET 0x008F0001000E0000LLU
#define LOG_COMP_RESTFILE 0x008F0001000F0000LLU

#define LOG_DEST_DEV_NULL 0x008F0000
#define LOG_DEST_PRINTF_STDOUT 0x008F0001
Expand Down

0 comments on commit adaa9c6

Please sign in to comment.