client_section-pipe-carbage-collector.patch by Petri Hintukainen

- Run section filter carbage collector when adding new filter.
  Carbage collector closes all filters that have already been
  closed by local VDR section handler.
  (without this, closed section filters are removed only when
  they receive data from server. If they wont, ...).
- Add locking to list handling (list is accessed from separate threads)
Modified Files:
	client/filter.c client/filter.h
This commit is contained in:
schmirl 2007-04-23 12:52:28 +00:00
parent 5f54824d3d
commit 6dd3cc412e
2 changed files with 38 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: filter.c,v 1.9 2007/04/23 12:01:33 schmirl Exp $ * $Id: filter.c,v 1.10 2007/04/23 12:52:28 schmirl Exp $
*/ */
#include "client/filter.h" #include "client/filter.h"
@ -155,9 +155,43 @@ cStreamdevFilters::~cStreamdevFilters() {
} }
int cStreamdevFilters::OpenFilter(u_short Pid, u_char Tid, u_char Mask) { int cStreamdevFilters::OpenFilter(u_short Pid, u_char Tid, u_char Mask) {
CarbageCollect();
cStreamdevFilter *f = new cStreamdevFilter(Pid, Tid, Mask); cStreamdevFilter *f = new cStreamdevFilter(Pid, Tid, Mask);
int fh = f->ReadPipe();
Lock();
Add(f); Add(f);
return f->ReadPipe(); Unlock();
return fh;
}
void cStreamdevFilters::CarbageCollect(void) {
LOCK_THREAD;
for (cStreamdevFilter *fi = First(); fi;) {
if (fi->IsClosed()) {
if (errno == ECONNREFUSED ||
errno == ECONNRESET ||
errno == EPIPE) {
ClientSocket.SetFilter(fi->Pid(), fi->Tid(), fi->Mask(), false);
Dprintf("cStreamdevFilters::CarbageCollector: filter closed: Pid %4d, Tid %3d, Mask %2x (%d filters left)",
(int)fi->Pid(), (int)fi->Tid(), fi->Mask(), Count()-1);
cStreamdevFilter *next = Prev(fi);
Del(fi);
fi = next ? Next(next) : First();
} else {
esyslog("cStreamdevFilters::CarbageCollector() error: "
"Pid %4d, Tid %3d, Mask %2x (%d filters left) failed",
(int)fi->Pid(), (int)fi->Tid(), fi->Mask(), Count()-1);
LOG_ERROR;
fi = Next(fi);
}
} else {
fi = Next(fi);
}
}
} }
cStreamdevFilter *cStreamdevFilters::Matches(u_short Pid, u_char Tid) { cStreamdevFilter *cStreamdevFilters::Matches(u_short Pid, u_char Tid) {

View File

@ -1,5 +1,5 @@
/* /*
* $Id: filter.h,v 1.2 2007/04/23 11:23:15 schmirl Exp $ * $Id: filter.h,v 1.3 2007/04/23 12:52:28 schmirl Exp $
*/ */
#ifndef VDR_STREAMDEV_FILTER_H #ifndef VDR_STREAMDEV_FILTER_H
@ -23,6 +23,7 @@ private:
protected: protected:
virtual void Action(void); virtual void Action(void);
void CarbageCollect(void);
public: public:
cStreamdevFilters(void); cStreamdevFilters(void);