|
@@ -113,17 +113,30 @@ int _ttail_search_closest_files_set_fsizes(ttail_t* t)
|
113
|
113
|
int _ttail_search_file_sorted(ttail_t* t)
|
114
|
114
|
{
|
115
|
115
|
/* files start & stop log tm, file start id = i*2 file stop = i*2+1 */
|
116
|
|
- struct tm *ftm;
|
|
116
|
+ struct tm *ftm;
|
|
117
|
+ size_t i;
|
117
|
118
|
|
118
|
119
|
ftm = malloc(sizeof(struct tm)*t->logfile_sz*2);
|
119
|
120
|
if(!ftm)
|
120
|
121
|
{
|
121
|
122
|
perror("Unable to allocate memory");
|
122
|
|
- return -1;
|
|
123
|
+ return -3;
|
|
124
|
+ }
|
|
125
|
+ for(i=0; i<t->logfile_sz; i++)
|
|
126
|
+ {
|
|
127
|
+ _ttail_file_minmax(t, 0, ftm+(i*2));
|
|
128
|
+ if(i)
|
|
129
|
+ {
|
|
130
|
+ if(ttail_tm_cmp(ftm+((i-1)*2)+1, ftm+i*2) > 0)
|
|
131
|
+ {
|
|
132
|
+ /* not sorted */
|
|
133
|
+ free(ftm);
|
|
134
|
+ return -1;
|
|
135
|
+ }
|
|
136
|
+ }
|
123
|
137
|
}
|
124
|
|
-
|
125
|
138
|
free(ftm);
|
126
|
|
- return -1;
|
|
139
|
+ return 0;
|
127
|
140
|
}
|
128
|
141
|
|
129
|
142
|
int _ttail_file_minmax(ttail_t* t, size_t id, struct tm tm[2])
|