diff options
| author | Louis Burda <quent.burda@gmail.com> | 2021-05-11 00:34:07 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2021-05-11 00:34:07 +0200 |
| commit | f1285b65d59119b71c7c4f98dddcf2d6969922be (patch) | |
| tree | 9cc6bc37cfcb188ce9b22b21b5a45f641d9f1bd6 | |
| parent | 15340585cb82677623c6b680c7b6f26040e044cd (diff) | |
| download | enowars5-service-stldoctor-f1285b65d59119b71c7c4f98dddcf2d6969922be.tar.gz enowars5-service-stldoctor-f1285b65d59119b71c7c4f98dddcf2d6969922be.zip | |
made docker setup more stable + small fixes
| -rwxr-xr-x | service/entrypoint.sh | 7 | ||||
| -rw-r--r-- | service/src/printdoc.c | 3 | ||||
| -rw-r--r-- | service/src/stlfile.c | 7 |
3 files changed, 12 insertions, 5 deletions
diff --git a/service/entrypoint.sh b/service/entrypoint.sh index 14cde26..f97f179 100755 --- a/service/entrypoint.sh +++ b/service/entrypoint.sh @@ -6,5 +6,8 @@ chown -R service:service "/data/" export RESULTDIR="/data" -servicecmd='socat TCP-LISTEN:9000,fork,reuseaddr EXEC:"/service/printdoc",raw,pty,echo=0,stderr' -exec su -s /bin/sh -c "$servicecmd" service +servicecmd='socat -T30 -s TCP-LISTEN:9000,reuseaddr,fork,end-close EXEC:"/service/printdoc",raw,pty,echo=0,stderr' + +while [ 1 ]; do + su -s /bin/sh -c "$servicecmd" service +done diff --git a/service/src/printdoc.c b/service/src/printdoc.c index 2bd24fd..0eb3127 100644 --- a/service/src/printdoc.c +++ b/service/src/printdoc.c @@ -241,7 +241,8 @@ main() if (exit || !*linebuf) break; if (*linebuf == '\n') continue; - linebuf[strlen(linebuf) - 1] = '\0'; + if (linebuf[strlen(linebuf) - 1] == '\n') + linebuf[strlen(linebuf) - 1] = '\0'; cp = strchr(linebuf, ' '); arg = cp ? cp + 1 : NULL; diff --git a/service/src/stlfile.c b/service/src/stlfile.c index 95d3a07..72868f8 100644 --- a/service/src/stlfile.c +++ b/service/src/stlfile.c @@ -254,10 +254,13 @@ parse_file(struct parseinfo *info, char *buf, size_t len) const char *tmp; char *bp; - if (len < 7) return FAIL; - if (info->valid) free_info(info); + if (len < 7) { + fprintf(stderr, "File too small!\n"); + return FAIL; + } + for (bp = buf; strchr(wsset, *bp); bp++); /* check bin vs ascii with first keyword */ |
