@@ -1834,24 +1834,24 @@ func IsRevTreeID(s string) bool {
18341834 return false
18351835}
18361836
1837+ // GetStackTrace will return goroutine stack traces for all goroutines in Sync Gateway.
18371838func GetStackTrace () string {
1838- // this nees logging in to warmn if we don;t successfully grab the stack in 10 tries
1839- // mnaybe use some switch retyr logic
1839+ // make 1MB buffer but if this buffer isn't big enough, runtime.Stack will
1840+ // return nothing, thus have 5 retires doubling the capacity each time.
18401841 buf := make ([]byte , 1 << 20 )
1841- count := 0
1842- for count < 10 {
1842+ for range 5 {
18431843 n := runtime .Stack (buf , true )
1844- fmt .Println ("n" , n )
18451844 if n < len (buf ) {
18461845 buf = buf [:n ]
18471846 break
18481847 }
18491848 buf = make ([]byte , 2 * len (buf ))
1850- count ++
18511849 }
18521850 return string (buf )
18531851}
18541852
1853+ // RotateProfilesIfNeeded will remove old files if there are more than
1854+ // 10 matching the given filename pattern.
18551855func RotateProfilesIfNeeded (filename string ) error {
18561856 existingFiles , err := filepath .Glob (filename )
18571857 if err != nil {
@@ -1871,6 +1871,7 @@ func RotateProfilesIfNeeded(filename string) error {
18711871 return multiErr .ErrorOrNil ()
18721872}
18731873
1874- func CreateFileInLoggingDirectory (filename string ) (* os.File , error ) {
1874+ // CreateFileInDirectory will create a file in directory specified by filename.
1875+ func CreateFileInDirectory (filename string ) (* os.File , error ) {
18751876 return os .Create (filename )
18761877}
0 commit comments