|
a/upmpd/ohmetacache.cxx |
|
b/upmpd/ohmetacache.cxx |
|
... |
|
... |
116 |
return (void*)1;
|
116 |
return (void*)1;
|
117 |
}
|
117 |
}
|
118 |
LOGDEB("dmcacheSave: got save task: " << tsk->m_cache.size() <<
|
118 |
LOGDEB("dmcacheSave: got save task: " << tsk->m_cache.size() <<
|
119 |
" entries to " << tsk->m_fn << endl);
|
119 |
" entries to " << tsk->m_fn << endl);
|
120 |
|
120 |
|
|
|
121 |
string tfn = tsk->m_fn + "-";
|
121 |
ofstream output(tsk->m_fn, ios::out | ios::trunc);
|
122 |
ofstream output(tfn, ios::out | ios::trunc);
|
122 |
if (!output.is_open()) {
|
123 |
if (!output.is_open()) {
|
123 |
LOGERR("dmcacheSave: could not open " << tsk->m_fn
|
124 |
LOGERR("dmcacheSave: could not open " << tfn
|
124 |
<< " for writing" << endl);
|
125 |
<< " for writing" << endl);
|
125 |
delete tsk;
|
126 |
delete tsk;
|
126 |
continue;
|
127 |
continue;
|
127 |
}
|
128 |
}
|
128 |
|
129 |
|
129 |
for (mcache_type::const_iterator it = tsk->m_cache.begin();
|
130 |
for (mcache_type::const_iterator it = tsk->m_cache.begin();
|
130 |
it != tsk->m_cache.end(); it++) {
|
131 |
it != tsk->m_cache.end(); it++) {
|
131 |
output << encode(it->first) << '=' << encode(it->second) << '\n';
|
132 |
output << encode(it->first) << '=' << encode(it->second) << '\n';
|
132 |
if (!output.good()) {
|
133 |
if (!output.good()) {
|
133 |
LOGERR("dmcacheSave: write error while saving to " <<
|
134 |
LOGERR("dmcacheSave: write error while saving to " <<
|
134 |
tsk->m_fn << endl);
|
135 |
tfn << endl);
|
135 |
break;
|
136 |
break;
|
136 |
}
|
137 |
}
|
137 |
}
|
138 |
}
|
138 |
output.flush();
|
139 |
output.flush();
|
139 |
if (!output.good()) {
|
140 |
if (!output.good()) {
|
140 |
LOGERR("dmcacheSave: flush error while saving to " <<
|
141 |
LOGERR("dmcacheSave: flush error while saving to " <<
|
141 |
tsk->m_fn << endl);
|
142 |
tfn << endl);
|
|
|
143 |
}
|
|
|
144 |
if (rename(tfn.c_str(), tsk->m_fn.c_str()) != 0) {
|
|
|
145 |
LOGERR("dmcacheSave: rename(" << tfn << ", " << tsk->m_fn << ")" <<
|
|
|
146 |
" failed: errno: " << errno << endl);
|
142 |
}
|
147 |
}
|
143 |
|
148 |
|
144 |
delete tsk;
|
149 |
delete tsk;
|
145 |
}
|
150 |
}
|
146 |
}
|
151 |
}
|