File tree 1 file changed +16
-0
lines changed 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,15 @@ bool FatVolume::allocateCluster(uint32_t current, uint32_t* next) {
84
84
find = m_allocSearchStart;
85
85
setStart = true ;
86
86
}
87
+ // Following loop may iterate over up to 268 million clusters, so we need to allow
88
+ // the OS/hardware to do its work occasionally during the search or a WDT error will
89
+ // occur on the ESP8266.
90
+ int yieldCnt = 5000 ;
87
91
while (1 ) {
92
+ if (!(--yieldCnt)) {
93
+ yieldCnt = 5000 ;
94
+ SysCall::yield ();
95
+ }
88
96
find++;
89
97
if (find > m_lastCluster) {
90
98
if (setStart) {
@@ -153,7 +161,15 @@ bool FatVolume::allocContiguous(uint32_t count,
153
161
}
154
162
endCluster = bgnCluster;
155
163
// search the FAT for free clusters
164
+ // Following loop may iterate over up to 268 million clusters, so we need to allow
165
+ // the OS/hardware to do its work occasionally during the search or a WDT error will
166
+ // occur on the ESP8266.
167
+ int yieldCnt = 5000 ;
156
168
while (1 ) {
169
+ if (!(--yieldCnt)) {
170
+ yieldCnt = 5000 ;
171
+ SysCall::yield ();
172
+ }
157
173
if (endCluster > m_lastCluster) {
158
174
// Can't find space.
159
175
DBG_FAIL_MACRO;
You can’t perform that action at this time.
0 commit comments