Commit 25813b22 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

1. Built in glibc 2.28 and gcc 8.2.0:

  mkfifo/fopen/fread/fwrite kind of worked with glibc 2.26 and gcc 7.2.0.
  With 2.28 named-pipe reading with fread would read the pipe only once for
  some reason - probably because it stopped being a 'blocking' call
  To fix - switched to open/read/poll combination - so none of glibc functions
  is used.

2. camogm_fifo_reader - test program - use with *_writer or just 'echo'
3. camogm_fifo_writer - test program
parent 64eeb889
GUIDIR = camogmgui
PROGS = camogm
TEST_PROG = camogm_test
TEST_PROG = camogm_test
TEST_PROG1 = camogm_fifo_writer
TEST_PROG2 = camogm_fifo_reader
PHPSCRIPTS = camogmstate.php $(GUIDIR)/camogmgui.php $(GUIDIR)/camogmgui.css $(GUIDIR)/camogmgui.js $(GUIDIR)/camogm_interface.php \
$(GUIDIR)/SpryTabbedPanels.css $(GUIDIR)/SpryTabbedPanels.js $(GUIDIR)/xml_simple.php $(GUIDIR)/SpryCollapsiblePanel.css \
$(GUIDIR)/SpryCollapsiblePanel.js
......@@ -12,7 +15,10 @@ IMAGES = $(GUIDIR)/images/filebrowser-01.gif $(GUIDIR)/images/filebrowser-bo
SRCS = camogm.c camogm_ogm.c camogm_jpeg.c camogm_mov.c camogm_kml.c camogm_read.c index_list.c camogm_align.c
TEST_SRC = camogm_test.c
TEST_SRC = camogm_test.c
TEST_SRC1 = camogm_fifo_writer.c
TEST_SRC2 = camogm_fifo_reader.c
OBJS = $(SRCS:.c=.o)
CFLAGS += -Wall -I$(STAGING_DIR_HOST)/usr/include-uapi
......@@ -28,17 +34,21 @@ BINDIR = /usr/bin/
WWW_PAGES = /www/pages
IMAGEDIR = $(WWW_PAGES)/images
all: $(PROGS) $(TEST_PROG)
all: $(PROGS) $(TEST_PROG) $(TEST_PROG1) $(TEST_PROG2)
$(PROGS): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(TEST_PROG): $(TEST_SRC:.c=.o)
$(TEST_PROG): $(TEST_SRC:.c=.o)
$(TEST_PROG1): $(TEST_SRC1:.c=.o)
$(TEST_PROG2): $(TEST_SRC2:.c=.o)
install: $(PROGS) $(PHPSCRIPTS) $(CONFIGS)
$(INSTALL) $(OWN) -d $(DESTDIR)$(BINDIR)
$(INSTALL) $(OWN) -m $(INSTMODE) $(PROGS) $(DESTDIR)$(BINDIR)
$(INSTALL) $(OWN) -m $(INSTMODE) $(TEST_PROG) $(DESTDIR)$(BINDIR)
$(INSTALL) $(OWN) -m $(INSTMODE) $(TEST_PROG1) $(DESTDIR)$(BINDIR)
$(INSTALL) $(OWN) -m $(INSTMODE) $(TEST_PROG2) $(DESTDIR)$(BINDIR)
$(INSTALL) $(OWN) -d $(DESTDIR)$(SYSCONFDIR)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(CONFIGS) $(DESTDIR)$(SYSCONFDIR)
$(INSTALL) $(OWN) -d $(DESTDIR)$(WWW_PAGES)
......
This diff is collapsed.
/** @brief This define is needed to use lseek64 and should be set before includes */
#define _LARGEFILE64_SOURCE
/** Needed for O_DIRECT */
#define _GNU_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <stdbool.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/fs.h>
#include <ctype.h>
#include <sys/uio.h>
#include <poll.h>
// set to 1 second
#define CAMOGM_TIMEOUT 1000
int main(int argc, char *argv[]){
int f_ok;
int ret;
int fer, feo;
long int ftl;
int i=0;
const char pipe_name[] = "/tmp/fifo_test";
int flags;
char cmdbuf[1024];
int fl;
int somecounter = 0;
int writecounter = 0;
FILE *cmd_file;
struct pollfd pfd;
pfd.events = POLLIN;
printf("This is reader. It creates FIFO: %s\n",pipe_name);
// always delete pipe if it exists
f_ok = access(pipe_name, F_OK);
ret = unlink(pipe_name);
if (ret && f_ok == 0) {
printf("Some error\n");
}
ret = mkfifo(pipe_name, 0666); //EEXIST
if (ret) {
if (errno==EEXIST){
printf("Pipe exists\n");
}
}
cmd_file = open(pipe_name, O_RDWR|O_NONBLOCK);
pfd.fd = cmd_file;
fcntl(cmd_file, F_SETFL, 0); /* disable O_NONBLOCK */
printf("Pipe is now open for reading\n");
while(true){
ret = poll(&pfd, 1, CAMOGM_TIMEOUT); /* poll to avoid reading EOF */
somecounter +=1;
if (ret==0) {
printf("TIMEOUT %d\n",somecounter);
}
if (pfd.revents & POLLIN){
printf("PostPoll %d %d, revents = %d, errno = %d\n",somecounter,ret,pfd.revents,errno);
fl = read(cmd_file, cmdbuf, sizeof(cmdbuf));
//clearerr(cmd_file);
if (fl>0) {
writecounter +=1;
}
if (fl<0) {
printf("Error?\n");
break;
}
//fl = read(cmd_file,cmdbuf,sizeof(cmdbuf));
if ((fl>10)||(somecounter>10000000)) {
break;
}
}
}
printf("EXIT! errno=%d writes=%d wdc=%d\n",errno,writecounter,somecounter);
return 0;
}
/** @brief This define is needed to use lseek64 and should be set before includes */
#define _LARGEFILE64_SOURCE
/** Needed for O_DIRECT */
#define _GNU_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <stdbool.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <linux/fs.h>
#include <ctype.h>
#include <sys/uio.h>
int main(int argc, char *argv[]){
FILE *cmd_file;
const char pipe_name[] = "/tmp/fifo_test";
const char message[] = "test";
int ret;
printf("This is writer\n");
cmd_file = fopen(pipe_name, "w");
while(true){
ret = fwrite(message,sizeof(char),sizeof(message),cmd_file);
printf("Wrote %d bytes, fwrite returned %d\n",sizeof(message),ret);
}
return 0;
}
......@@ -1017,8 +1017,8 @@ void *reader(void *arg)
.sockfd_const = &sockfd,
.sockfd_temp = &fd
};
memset(&index_dir, 0, sizeof(struct disk_index));
memset(&index_sparse, 0, sizeof(struct disk_index));
memset(&index_dir, 0, sizeof(struct disk_idir));
memset(&index_sparse, 0, sizeof(struct disk_idir));
prep_socket(&sockfd, state->sock_port);
pthread_cleanup_push(exit_thread, &exit_state);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment