git-svn: trunk@2958
Tomasz Kojm authored on 2007/03/21 04:34:51... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Tue Mar 20 18:42:00 CET 2007 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * freshclam: release dbdir write-lock before notifying clamd (bb#401) |
|
4 |
+ |
|
1 | 5 |
Tue Mar 20 16:21:39 CET 2007 (tk) |
2 | 6 |
--------------------------------- |
3 | 7 |
* freshclam/manager.c: fix error handling in --no-dns mode (bb#418) |
... | ... |
@@ -55,8 +55,6 @@ |
55 | 55 |
#include "shared/output.h" |
56 | 56 |
#include "shared/misc.h" |
57 | 57 |
|
58 |
-#include "libclamav/lockdb.h" |
|
59 |
- |
|
60 | 58 |
#include "execute.h" |
61 | 59 |
#include "manager.h" |
62 | 60 |
#include "mirman.h" |
... | ... |
@@ -163,17 +161,8 @@ static int download(const struct cfgstruct *copt, const struct optstruct *opt, c |
163 | 163 |
logg("^You must specify at least one database mirror.\n"); |
164 | 164 |
return 56; |
165 | 165 |
} else { |
166 |
- while(cli_writelockdb(datadir, 0) == CL_ELOCKDB) { |
|
167 |
- logg("*Waiting to lock database directory: %s\n", datadir); |
|
168 |
- sleep(5); |
|
169 |
- if(++try > 12) { |
|
170 |
- logg("!Can't lock database directory: %s\n", datadir); |
|
171 |
- return 61; |
|
172 |
- } |
|
173 |
- } |
|
174 |
- try = 0; |
|
175 | 166 |
while(cpt) { |
176 |
- ret = downloadmanager(copt, opt, cpt->strarg); |
|
167 |
+ ret = downloadmanager(copt, opt, cpt->strarg, datadir); |
|
177 | 168 |
alarm(0); |
178 | 169 |
|
179 | 170 |
if(ret == 52 || ret == 54 || ret == 58 || ret == 59) { |
... | ... |
@@ -192,11 +181,9 @@ static int download(const struct cfgstruct *copt, const struct optstruct *opt, c |
192 | 192 |
} |
193 | 193 |
|
194 | 194 |
} else { |
195 |
- cli_unlockdb(datadir); |
|
196 | 195 |
return ret; |
197 | 196 |
} |
198 | 197 |
} |
199 |
- cli_unlockdb(datadir); |
|
200 | 198 |
} |
201 | 199 |
|
202 | 200 |
return ret; |
... | ... |
@@ -68,6 +68,7 @@ |
68 | 68 |
#include "libclamav/others.h" |
69 | 69 |
#include "libclamav/str.h" |
70 | 70 |
#include "libclamav/cvd.h" |
71 |
+#include "libclamav/lockdb.h" |
|
71 | 72 |
|
72 | 73 |
#ifndef O_BINARY |
73 | 74 |
#define O_BINARY 0 |
... | ... |
@@ -1075,11 +1076,11 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig |
1075 | 1075 |
return 0; |
1076 | 1076 |
} |
1077 | 1077 |
|
1078 |
-int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, const char *hostname) |
|
1078 |
+int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, const char *hostname, const char *dbdir) |
|
1079 | 1079 |
{ |
1080 | 1080 |
time_t currtime; |
1081 | 1081 |
int ret, updated = 0, outdated = 0, signo = 0; |
1082 |
- unsigned int ttl; |
|
1082 |
+ unsigned int ttl, try = 0; |
|
1083 | 1083 |
char ipaddr[16], *dnsreply = NULL, *pt, *localip = NULL, *newver = NULL; |
1084 | 1084 |
const char *arg = NULL; |
1085 | 1085 |
struct cfgstruct *cpt; |
... | ... |
@@ -1167,6 +1168,19 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
1167 | 1167 |
localip = cpt->strarg; |
1168 | 1168 |
} |
1169 | 1169 |
|
1170 |
+ while(cli_writelockdb(dbdir, 0) == CL_ELOCKDB) { |
|
1171 |
+ logg("*Waiting to lock database directory: %s\n", dbdir); |
|
1172 |
+ sleep(5); |
|
1173 |
+ if(++try > 12) { |
|
1174 |
+ logg("!Can't lock database directory: %s\n", dbdir); |
|
1175 |
+ if(dnsreply) |
|
1176 |
+ free(dnsreply); |
|
1177 |
+ if(newver) |
|
1178 |
+ free(newver); |
|
1179 |
+ return 61; |
|
1180 |
+ } |
|
1181 |
+ } |
|
1182 |
+ |
|
1170 | 1183 |
if(cfgopt(copt, "HTTPProxyServer")->enabled) |
1171 | 1184 |
mirman_read("mirrors.dat", &mdat, 0); |
1172 | 1185 |
else |
... | ... |
@@ -1182,6 +1196,7 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
1182 | 1182 |
free(newver); |
1183 | 1183 |
|
1184 | 1184 |
mirman_write("mirrors.dat", &mdat); |
1185 |
+ cli_unlockdb(dbdir); |
|
1185 | 1186 |
return ret; |
1186 | 1187 |
|
1187 | 1188 |
} else if(ret == 0) |
... | ... |
@@ -1196,6 +1211,7 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
1196 | 1196 |
free(newver); |
1197 | 1197 |
|
1198 | 1198 |
mirman_write("mirrors.dat", &mdat); |
1199 |
+ cli_unlockdb(dbdir); |
|
1199 | 1200 |
return ret; |
1200 | 1201 |
|
1201 | 1202 |
} else if(ret == 0) |
... | ... |
@@ -1205,6 +1221,7 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
1205 | 1205 |
free(dnsreply); |
1206 | 1206 |
|
1207 | 1207 |
mirman_write("mirrors.dat", &mdat); |
1208 |
+ cli_unlockdb(dbdir); |
|
1208 | 1209 |
|
1209 | 1210 |
if(updated) { |
1210 | 1211 |
if(cfgopt(copt, "HTTPProxyServer")->enabled) { |
... | ... |
@@ -1255,7 +1272,7 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
1255 | 1255 |
free(cmd); |
1256 | 1256 |
if(newver) |
1257 | 1257 |
free(newver); |
1258 |
- return 0; |
|
1258 |
+ return 75; |
|
1259 | 1259 |
} |
1260 | 1260 |
|
1261 | 1261 |
*pt = 0; pt += 2; |
... | ... |
@@ -23,6 +23,6 @@ |
23 | 23 |
#include "shared/cfgparser.h" |
24 | 24 |
#include "shared/options.h" |
25 | 25 |
|
26 |
-int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, const char *hostname); |
|
26 |
+int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, const char *hostname, const char *dbdir); |
|
27 | 27 |
|
28 | 28 |
#endif |