Created
May 3, 2016 08:35
-
-
Save karolhrdina/13a23c33c5168e76b061927c0ac7ebea to your computer and use it in GitHub Desktop.
PROBLEM: zfile_eof () does not work OR i am not using it propertly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tried agains latest upstream master | |
# libzqm commit fc7d5e7fbb64e4a0feaf6b2dbce3676678e664d6 | |
# czmq: commit 6634a6c26b79b55f606a823be728e1eed1441e83 | |
rm -f test | |
gcc -lczmq test.c -o test | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123456789 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <czmq.h> | |
static const char *STATE_PATH = "."; | |
static const char *STATE_FILE = "state_file"; | |
void | |
test_zfile_eof () { | |
zfile_t *file = zfile_new (STATE_PATH, STATE_FILE); | |
assert (file); | |
int rv = zfile_input (file); | |
assert (rv != -1); | |
uint64_t offset = 0; | |
while (!zfile_eof (file)) { | |
zchunk_t *chunk = zfile_read (file, 1, offset); | |
assert (chunk); | |
offset += 1; | |
zfile_restat (file); | |
zsys_debug ("Offset == % "PRIu64"\tByte read (hex) %x", offset, *zchunk_data (chunk)); | |
zchunk_destroy (&chunk); | |
zclock_sleep (300); | |
} | |
zfile_close (file); | |
zfile_destroy (&file); | |
} | |
int main () { | |
zsys_debug ("zfile_eof () test start"); | |
test_zfile_eof (); | |
zsys_debug ("test stop"); | |
return EXIT_SUCCESS; | |
} |
Author
karolhrdina
commented
May 3, 2016
- I would expect the while () cycle to end, but it reads from file indefinitely
- The zfile_restat (file); is probably redundant
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment