projects
/
record-dvb
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4710a9f
)
better reconnect-logic
author
michael
<michael>
Sat, 1 Jul 2006 22:51:40 +0000
(22:51 +0000)
committer
michael
<michael>
Sat, 1 Jul 2006 22:51:40 +0000
(22:51 +0000)
record-dvb.c
patch
|
blob
|
blame
|
history
diff --git
a/record-dvb.c
b/record-dvb.c
index 02fcd5157c2d9d3ae17ae6231ebe19132144e8ca..38609a4996c27cf7caea23c89a8469e22c57fe00 100644
(file)
--- a/
record-dvb.c
+++ b/
record-dvb.c
@@
-20,6
+20,7
@@
void record(int(*open_fn)(char *), char *url, char *outfile, int duration)
{
struct timeval start, curr;
int bytes, recvd, written, count = 0;
{
struct timeval start, curr;
int bytes, recvd, written, count = 0;
+ int error_sleep = 0;
char buffer[CHUNKSIZE];
int in, out;
char buffer[CHUNKSIZE];
int in, out;
@@
-39,13
+40,25
@@
void record(int(*open_fn)(char *), char *url, char *outfile, int duration)
curr = start;
do {
curr = start;
do {
- if ((recvd = recv(in, buffer, CHUNKSIZE, 0)) < 1) {
- /* TODO: Insert better connection-loss recovery here */
+ if (error_sleep) {
+ sleep(error_sleep);
+ printf("Reconnecting... ");
if ((in = (*open_fn)(url)) < 0) {
if ((in = (*open_fn)(url)) < 0) {
- sleep(1);
+ if (error_sleep < 60)
+ error_sleep *= 2;
+
+ printf("failed\n");
continue;
continue;
+ } else {
+ printf("succeeded\n");
+ error_sleep = 0;
}
}
}
}
+
+ if ((recvd = recv(in, buffer, CHUNKSIZE, 0)) < 1) {
+ error_sleep = 1;
+ continue;
+ }
written = 0;
do {
if ((bytes = write(out, buffer, recvd-written)) < 0) {
written = 0;
do {
if ((bytes = write(out, buffer, recvd-written)) < 0) {
Impressum
,
Datenschutz